Function error using Input Command

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

回答(1 个)

Walter Roberson
Walter Roberson 2018-4-30
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.

类别

帮助中心File Exchange 中查找有关 Software Development Tools 的更多信息

产品

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by