Increment the value inside another loop
조회 수: 1 (최근 30일)
이전 댓글 표시
for i=1:10
if(true)
while(true)
i=i+1;
end
end
end
will this increment or update the value of i ?
댓글 수: 2
채택된 답변
Hunter Bates
2018년 4월 25일
@Mushahid Shamim: This will run in a inf loop. Need a condition to break the while statement. for i=1:10 if(true) while(true) i=i+1 break end end end end Please describe the workflow which you are trying to achieve, assuming this isn't for m-code 101
댓글 수: 3
Dennis
2018년 4월 26일
why should your while loop break? I am pretty sure that your for loop doesnt even care if you change i somewhere it will still run from 1:10.
If you want your inner loop to iterate 4 times why are you using while?
while it<=10
for i=1:4
it=it+1;
end
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!