conditional statement not working correctly

I am trying to have my conditional statement check to see if input values that are converted to numbers are within a certain range however whenever it is run it only puts out the else value. Wondering if anyone can help so that it checks the correct ranges
%request for input for lux and heat [F]
Temp = input('Please Enter a Temperature In Farienheit [F]: ',"s");
Lux = input('Please Enter a Value for light [lx]: ',"s");
%convert temp to K
TempK = str2double(Temp) +273;
Lux = str2double(Lux);
%conditionals
if(0>Lux && Lux>100000) && (260>TempK && TempK>310)
error('Both values were not in Range')
elseif (0>Lux) && (Lux>100000)
error('The Lux Value was not between 0-100,000 lx')
elseif (260>TempK) && (TempK>310)
error('The Temperature Value was out of 260-310K range')
else
error('enter values')
end

Respuestas (1)

Steven Lord
Steven Lord el 21 de Jun. de 2020
Can you tell me one value for Lux that is simultaneously less than 0 and greater than 100000?
(0>Lux && Lux>100000)
You want to use or (||) instead of and (&&) here and in some or all of your other conditions.

Productos

Versión

R2019a

Etiquetas

Preguntada:

el 21 de Jun. de 2020

Respondida:

el 21 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by