Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

break out of if statement to else

1 Ansicht (letzte 30 Tage)
Aneesh Vasudev
Aneesh Vasudev am 24 Mai 2018
Geschlossen: Aneesh Vasudev am 26 Mai 2018
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?

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 24 Mai 2018
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.

Diese Frage ist geschlossen.

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by