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

 Respuesta aceptada

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

1 comentario

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

L
L
el 13 de Nov. de 2017

Comentada:

L
L
el 13 de Nov. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by