MATLAB: How to save the break points in the MATLAB files between MATLAB sessions

debugdebuggerdebuggingeditorMATLABpausestop

I have a long MATLAB file that I want to debug. I add breakpoints to my file, however, when I close MATLAB, all of these breakpoints are lost and I have to recreate them in my next MATLAB session.

Best Answer

Since MATLAB R2006b, you can save breakpoints and reuse them in a later session by saving the status of breakpoints to a MAT-file using
s = dbstatus
and restoring the breakpoint status at a later time by loading the MAT-file using
dbstop(s)
which is a new option, introduced in MATLAB R2006b.
See the example in the dbstatus reference page of the documentation by running
doc dbstatus
Prior to MATLAB R2006b, you can workaround this issue by inserting the following line of code where you would like to set a breakpoint:
keyboard
The keyboard function has the same functionality of a breakpoint, but it can be saved in the code.