필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

break out of if statement to else

조회 수: 1 (최근 30일)
Aneesh Vasudev
Aneesh Vasudev 2018년 5월 24일
마감: Aneesh Vasudev 2018년 5월 26일
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?

답변 (1개)

Fangjun Jiang
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.

이 질문은 마감되었습니다.

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by