Force return from function while debugging
4 次查看(过去 30 天)
显示 更早的评论
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?
回答(1 个)
Image Analyst
2017-3-10
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 个评论
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!