답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 12월 9일
편집: Andrei Bobrov 2013년 12월 9일

0 개 추천

k = 0;
x = 0;
while x >= 0
k = k + 1;
x = 50 - k^2;
end
y = sqrt(x);

댓글 수: 2

x =
-14 ? why?
x have to plus (+)
Not in your code. Your "for" loop tests x<0 after it sets x to the new value. So the loop is not going to end until it is already true that x<0.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2013년 12월 9일

댓글:

2013년 12월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by