Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Problem executing While loop
조회 수: 6 (최근 30일)
이전 댓글 표시
So I'm trying to change my code from a for loop to while loop to display numbers from 10 to 30 and skips numbers from 15 to 20 and also 28. I did the for loop but however when i try to write it using a while loop i get an error.
This is for my for loop:
clear;
disp('This is the for loop version')
for k = 10:30
if (k > 15 && k < 20) || (k == 28)
continue
end
disp(k)
end
here is my while loop:
clear;
disp('This is the for while version')
k = 10;
while( k <= 30 )
if (k > 15 && k < 20) || (k == 28)
disp(k);
k = k + 1;
end
end
Also how do i stop the while loop from running? when i hit the run button it never stop running.
Thanks
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!