I am trying to write a simple function for change of temperature from Fahrenheit to Celsius but i could not. I have been trying to do it from last about 4 hours, and it drives me almost crazy... well what i wrote in m file is
function f = Fahrenheit(c)
% gives temp in Fahrenheit
%converts Celcius to Fahrenheit
f = c*9/5+32
But when i try to run it the commend window gives following error
??? Input argument "c" is undefined.
Error in ==> forenheit at 4 f = c*9/5+32
I am unable to figure out where is the problem. Whereas I have just written two other simple functions successfully. But this one and and another one for calculation of area of circle are not working at all. I shallbe really thankfull for any help
No products are associated with this question.
CelsiusToFahrenheit = @(c)c*9/5+32
>> CelsiusToFahrenheit(15) ans = 59
You need to store your function in Fahrenheit.m . You currently have it stored in forenheit.m
You cannot run the program by pressing F5. Instead, at the MATLAB command line, you need to call the routine as a function. To use Andrei's sample value, at the command line type in
Later when you get the above working, you will need to recode the problem, as your current code converts Celsius to Fahrenheit, whereas your problem description indicates you need to convert the other way around.