필터 지우기
필터 지우기

How to ignore part of for loops for manual runs?

조회 수: 1 (최근 30일)
Wolfgang McCormack
Wolfgang McCormack 2021년 3월 11일
답변: Jan 2021년 3월 11일
Hi everyone,
I have two for loops within each other. Some parts are dependant on the inner loop j. So to finish each loop of i, the entire j should be ran because there are some code out of j that depend on the entire j loop. How can I bypass those lines so that the code foes to the next loop of i when I intend to only run j=1:10
i = 1:100
j = 1:20
modifications
end of j
some modifications based on the entire j (I want to bypass this part so that j = 1:10 runs in its own loop and moves to the next i afterwards automatically)
endof i

채택된 답변

Jan
Jan 2021년 3월 11일
for i = 1:100
if condition
nj = 10;
else
nj = 20;
end
for j = 1:nj
...
end
end
Or maybe:
for i = 1:100
for j = 1:20
...
if condition & j == 10
break; % Exit for j loop early
end
end
end

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by