change the for loop

조회 수: 1 (최근 30일)
Konstantinos Kontos
Konstantinos Kontos 2012년 5월 31일
How can i put the for loop 10 times forward when an if statement is true?

채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 31일
If you are asking how you can skip 10 iterations of the for loop if an "if" statement is true, then the answer is that you cannot. You can, though, structure your loop like
num_to_skip = 0;
for K = 1 : 100
if num_to_skip > 0
num_to_skip = num_to_skip - 1;
continue
end
[...]
if YourCondition
num_to_skip = 10;
continue
end
[...]
end

추가 답변 (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