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

 採用された回答

Geoff Hayes
Geoff Hayes 2019 年 2 月 13 日
編集済み: Geoff Hayes 2019 年 2 月 13 日

1 投票

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.

1 件のコメント

Josh Jones
Josh Jones 2019 年 2 月 14 日
Thank you for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

製品

リリース

R2018a

タグ

質問済み:

2019 年 2 月 13 日

コメント済み:

2019 年 2 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by