How to ignore part of for loops for manual runs?

1 次查看(过去 30 天)
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