hello, how do i make the user enter only positive number in an array using while loop to check positivity? thanks

 採用された回答

Jan
Jan 2017 年 11 月 13 日

0 投票

ready = false;
while ~ready
d = input('Please input a positive number: ');
ready = (d > 0);
end

1 件のコメント

L
L 2017 年 11 月 13 日
When i tested this code, i wrote a matrix of 2 negative numbers and one postive but it accepted the matrix.

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

その他の回答 (0 件)

カテゴリ

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

質問済み:

L
L
2017 年 11 月 13 日

コメント済み:

L
L
2017 年 11 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by