How do I break out of nested loops using the BREAK command in MATLAB 7.7 (R2008b)?

282 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
This functionality is not availble when using the function BREAK. BREAK will only break out of the loop in which it was called.
As a workaround, you can use a flag variable along with BREAK to break out of nested loops.
flag=0;
for i=1:10
for j=1:5
flag=1;
break
end
if(flag==1)
break
end
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by