Why does the Editor/Debugger not stop on breakpoints set in my MATLAB file function that is called from a script?

8 views (last 30 days)
I have breakpoints set before I run my code. However, when I run the code, the debugger does not stop at the breakpoints, and the breakpoints are removed.
Also, I notice that after I stop my script, the breakpoints are cleared. So, if something is clearing the breakpoints, why is the editor not reflecting this clearing immediately?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 May 2010
Check for a CLEAR ALL commands anywhere before the breakpoint. As documented in the help for the CLEAR function:
clear all
clears all of the debug breakpoints.
You can resolve the breakpoint issue by commenting out all lines of code that refer to any incarnation of CLEAR that encompasses CLEAR ALL. There are a few CLEAR commands that encompass CLEAR ALL such as CLEAR JAVA. See the following URL for more information on the CLEAR command:
<http://www.mathworks.com/access/helpdesk/help/techdoc/ref/clear.html>
Concerning the delayed update of the editor window to reflect that breakpoints have been cleared, it is not possible to have an immediate update of the editor when breakpoints are cleared in the editor.
  2 Comments
Chuck
Chuck on 18 Jun 2016
Edited: Chuck on 18 Jun 2016
Thanks for this answer, it was really helpful.
But I have to tell that it is really annoying. Clear all should not clear the breakpoints.
Walter Roberson
Walter Roberson on 19 Jun 2016
clear all should only ever be used when you want to effectively reset your MATLAB session without bothering to quit MATLAB and restart it. When you are doing that, it does not make sense to keep breakpoints. You should be looking at clearvars instead of clear all
If you really need to keep breakpoints but want all files unloaded from memory and so on, then assign the output of dbstatus() to a variable, save that variable, clear all, load the file, pass the loaded variable to dbstop . You could create a script for this purpose. But again, chances are high you are overusing clear all
clear all should have been named illudium q-36 because it should be thought of as blowing your session to smithereens.

Sign in to comment.

More Answers (0)

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!