loop stop executing after executing nested if statement
显示 更早的评论
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 个)
madhan ravi
2018-10-21
for i = 1:m
do something;
for j = 1:n
do something;
if conditionIsTrue
do something;
else
continue
end
end
end
4 个评论
Liu Jian
2018-10-21
madhan ravi
2018-10-21
what are your operations?
Liu Jian
2018-10-24
madhan ravi
2018-10-24
Accept the answer so that other people know the question is solved
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!