Why am I coming up with an undefined function or variable on this simple temperature script?
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Common Operations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!