Why am I coming up with an undefined function or variable on this simple temperature script?
古いコメントを表示
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Common Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!