Filter löschen
Filter löschen

Force return from function while debugging

3 Ansichten (letzte 30 Tage)
David K
David K am 10 Mär. 2017
Kommentiert: Image Analyst am 11 Mär. 2017
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 Kommentare
John Chilleri
John Chilleri am 10 Mär. 2017
Hello,
return works for me. Are you defining the outputs of the function before the return?
David K
David K am 10 Mär. 2017
Yes, the outputs are defined before I type return. If they were not, I would get an error when I try to return.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 10 Mär. 2017
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 Kommentare
David K
David K am 11 Mär. 2017
My problem is that I don't actually have an if and return statement written in the code. Or rather, the one in the code does other things within the if statement that I don't want.
Image Analyst
Image Analyst am 11 Mär. 2017
Unfortunately MATLAB does not have "edit and continue" like Microsoft Visual Studio does, where you can do exactly what you're trying to do.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by