Write a function that writes a series of random Fahrenheit t
Solution
//Tested on octave online
clear all
echo off all
name=input(\'Please enter the name of your file\',\'s\')
itr=input(\'Please enter the number of iterations\')
vec=[]
i=1
function result = ftoc(ftemp)
%Convert the values from F to C using the conversion factor
%C = (F – 32) * 5/9
result = (ftemp-32)*5/9;
%In the above statement you can also use (ftemp-32)*(5/9) or many other
end
fid=fopen(name,\'w\');
fprintf(fid, \'Fahrenheit Celsius\ \');
for x=1:itr
random_value=randi([32 212],1,1)
ctemp=ftoc(random_value)
fprintf(fid, \'%.2f %.2f \ \',random_value,ctemp);
end
fclose(fid)
/***************output**************/
Fahrenheit Celsius
77.00 25.00
188.00 86.67
58.00 14.44
192.00 88.89
186.00 85.56
60.00 15.56
part 2:
================
clear all
echo off all
name=input(\'Please enter the name of your file\',\'s\')
vec=[]
i=1
m=dlmread(name)
[rows, columns] = size(m)
for row=2:rows
vec(i)=m(row,2)
i=i+1
end
maximum=max(vec);
minimum=min(vec);
mean_value=mean(vec)
fprintf(\'Maximum element is %.2f \ \',maximum)
fprintf(\'Minimum Element is %.2f \ \',minimum)
fprintf(\'Mean is %.2f \ \',mean_value)
/*************output*************/
Thanks a lot

