Why am I coming up with an undefined function or variable on this simple temperature script?
Show older comments
I'm writing a very simple temperature conversion script, and keep getting the undefined error. Here is the script:
function[y] = temp_conversion(x,unit)
if strcmp(unit,'Farenheit');
y = (x - 32)*(5/9);
elseif strcmp(unit,'Centigrade');
y = (x * (9/5)) + 32;
end
When I call it in matlab using
[y] = temp_conversion(25,Farenheit)
or [y] = temp_conversion(25,Centigrade)
I will get
"undefined function or variable 'Farenheit'." or "undefined function or variable 'Centigrade'." respectively.
I feel like I am missing something very simple, and am looking for some guidance, hope to hear from you guys.
Accepted Answer
More Answers (0)
Categories
Find more on Common Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!