Function error using Input Command
Mostra commenti meno recenti
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
Risposte (1)
Walter Roberson
il 30 Apr 2018
0 voti
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.
Categorie
Scopri di più su Software Development Tools in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!