loop stop executing after executing nested if statement
Mostra commenti meno recenti
I wrote a nested loop like below:
for i = 1:m
do something;
for j = 1:n
do something;
if conditionIsTrue
do something; %without continue or break
end
end
endBut the loop ends after the first time the condition in if statement is executed and return incorrect result, I tried to modify the code as below:
for i = 1:m
do something;
for j = 1:n
do something;
if conditionIsTrue
do something;
continue
else
continue
end
end
end
The problem's still there. How can I deal with this problem?1 Commento
Liu Jian
il 24 Ott 2018
Risposte (1)
madhan ravi
il 21 Ott 2018
for i = 1:m
do something;
for j = 1:n
do something;
if conditionIsTrue
do something;
else
continue
end
end
end
4 Commenti
Liu Jian
il 21 Ott 2018
madhan ravi
il 21 Ott 2018
what are your operations?
Liu Jian
il 24 Ott 2018
madhan ravi
il 24 Ott 2018
Accept the answer so that other people know the question is solved
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!