so i am trying to make this code have the user enter a positive integer, and if it isnt positive, then it needs to ask them over and over again until a positive integer is inputted. then continue with the code, but my code is only asking like 3 times im new to coding and matlab, can anyone help me out?

2 件のコメント

Colby Jennings
Colby Jennings 2021 年 3 月 4 日
update... i see why it is happening three times, back down to second input stays....
Colby Jennings
Colby Jennings 2021 年 3 月 4 日
i cant figure ou loops lol

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

 採用された回答

David Hill
David Hill 2021 年 3 月 4 日

0 投票

while 1
a=input('Please input a postive integer');
if isequal(a,floor(a))&&a>0
break;
end
display('a is not a positive integer');
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by