필터 지우기
필터 지우기

while loop keeps running indefinitely

조회 수: 1 (최근 30일)
Khoo
Khoo 2013년 8월 21일
Why my code is not working? It keeps running indefinitely...
z0=[0.3 0.5 0.2];
test=0;
while test==0
disp('checking');
if exp(z0(2)*(1-z0(1)))<(1/z0(3))
z0=z;
else
r1 = 0 + (1-0).*rand(1,1);
r2= 0 + (10-0).*rand(1,1);
r3= 0 + (1-0).*rand(1,1);
z0=[r1 r2 r3];
end
test=0;
end

채택된 답변

James Tursa
James Tursa 2013년 8월 21일
You never set test to anything other than 0, so the loop condition is always true.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by