While Loop Question - Will not properly execute

Can anyone help me out on why this while loop will not execute properly when ran through Matlab?
% Until good height, prompt user to enter a value for height in inches
inches = input ('Enter height in inches(59-78): ');
while (inches <= 59) && (inches >= 78)
disp('not between 59-78');
inches = input('Enter height in inches(59-78): ');
end

 Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 13 Feb. 2019
Bearbeitet: Geoff Hayes am 13 Feb. 2019

1 Stimme

Josh - you probably want to use OR instead of AND
while (inches < 59) || (inches > 78)
Note also how we use < and > since 59 and 78 are valid inputs.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by