Azzera filtri
Azzera filtri

How to ignore part of for loops for manual runs?

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Jan
Jan il 11 Mar 2021
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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by