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