Force return from function while debugging
이전 댓글 표시
I am debugging a program and would like to return from a subfunction without completing the function. For example, you can write in code:
if(conditionMet)
return;
end
If the condition is met, it will force the function to end early and continue in the caller code. While I am debugging, I would like to force the function to end early as if I had encountered a return command. When I simply type return while in debug mode, nothing appears to happens. Is there a way to force a function to end early and continue running?
댓글 수: 2
John Chilleri
2017년 3월 10일
Hello,
return works for me. Are you defining the outputs of the function before the return?
David K
2017년 3월 10일
답변 (1개)
Image Analyst
2017년 3월 10일
0 개 추천
When you type return in the command window, where does the arrow in the edit window point to? Doesn't it point to a new location? It will probably point at the function call in your main routine, where you had entered the function. Just hit F10 or click Step over icon at that point.
댓글 수: 4
David K
2017년 3월 10일
Image Analyst
2017년 3월 10일
It doesn't appear like you can do that. Clicking step out just finishes the function as normal, so it appears you can only do
conditionMet = true;
and then click Step out and then it will return when it hits the "if" again, if it does, or hits some other similar code that can toss you out.
David K
2017년 3월 11일
Image Analyst
2017년 3월 11일
Unfortunately MATLAB does not have "edit and continue" like Microsoft Visual Studio does, where you can do exactly what you're trying to do.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!