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

 Akzeptierte Antwort

Jan
Jan am 13 Nov. 2017

0 Stimmen

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

1 Kommentar

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

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

Gefragt:

L
L
am 13 Nov. 2017

Kommentiert:

L
L
am 13 Nov. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by