Function error using Input Command
Mostrar comentarios más antiguos
I am making a function for a class project and I am having trouble finding and fixing the error. When I try to run this function it asks me to input the type of metal I am using but after I type in Al1 for example, it keeps asking me to input the type of metal again. If I type in something other than Al1, nothing happens and it asks for the metal again. How do I fix this?
The function looks like this:
function [k]=ThCond(T)
m=input('What metal are you using?','s');
if m=='Al1'
if (298<=T)&&(T<=840)
k=149.7+0.0809*T-(1*10^-4)*T^2;
end
else fprintf('Please enter a valid temperature.\n');
end
end
Respuestas (1)
Walter Roberson
el 30 de Abr. de 2018
0 votos
You should be using strcmp() instead of == to compare character vectors.
That code itself would not prompt a second time for input, but it could be that you are calling the code inside a loop.
Categorías
Más información sobre Software Development Tools 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!