Info
此问题已关闭。 请重新打开它进行编辑或回答。
break out of if statement to else
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I would like to achieve the following:
if condition1
statements...
if condition2
break % move to else
end
statements...
else
statements...
end
Of course, I could simply put the statements in the else block into the nested if (i.e. if condition2). But is there any other way/command to do this?
0 个评论
回答(1 个)
Fangjun Jiang
2018-5-24
No such capability in MATLAB. I am sure you can adjust your code flow to achieve your goal without jumping around the code, which is not a good practice.
The "break" function only works for "for" and "while" loop in MATLAB.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!