필터 지우기
필터 지우기

using return command before codes

조회 수: 2 (최근 30일)
sermet
sermet 2015년 6월 6일
답변: the cyclist 2015년 6월 6일
while (criterion for loop)
iteration=iteration+1;
%codes to perform
if iteration==200
errordlg('iteration cannot be converged', 'Error!', 'modal')
return
end
end
%other codes need to be performed independently after the above loop
%In this example, if iteration numbers reach 200, return command terminates the loop to eliminate infinite loop. But there are other codes right after the loop which need to be executed. How can I continue to execute other codes outside the loop with using return command.

채택된 답변

the cyclist
the cyclist 2015년 6월 6일
It sounds like you want the break command rather than return command. A similar one is the continue command, but I don't think that's what you want in this case.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by