MATLAB: Function that converts Celsius to Fahrenheit and prints it to a file

input argumentMATLABwrite to a file

function Y=CelToFar(Cel)
Far=((9*Cel/5)+32);
X = [Far, Cel];
fileID = fopen('ftoc.txt','w');
fprintf(fileID,'%6s %12s\n','Far','Cel');
fprintf(fileID,'%6.2f %12.8f\n', X);
fclose(fileID);
After running I get this
CelToFar
Not enough input arguments.
Error in CelToFar (line 7)
Far=((9*Cel/5)+32);

Best Answer

Error in CelToFar (line 7)
Far=((9*Cel/5)+32);
Here it is- I assumed you pass the single aruments (scalar) at a time, if large array Cel data, also you can do that.
function X=CelToFar(Cel)
Far=(9*Cel)/5+32;
X = [Far, Cel]; % here I have changed the output arguments as X, as you defined initially
Save the function in new Matlab file (save it name as CelToFar.m). Now call the function from another Matlab main script or commnad window-
>> result=CelToFar(20)
result =
68 20
I hope rest you can do the print..
Good Luck!