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

 Réponse acceptée

Jan
Jan le 13 Nov 2017
ready = false;
while ~ready
d = input('Please input a positive number: ');
ready = (d > 0);
end

1 commentaire

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Question posée :

L
L
le 13 Nov 2017

Commenté :

L
L
le 13 Nov 2017

Community Treasure Hunt

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

Start Hunting!

Translated by