问题
I have a habit of beginning all my MATLAB scripts with clear all; close all; clc. While it has been a very useful line, as soon as it executes, it wipes out all my breakpoints. Is there a simple way to avoid that?
回答1:
I have solved this issue by creating a script that saves and reloads breakpoints. For convenience, you can even put it into a shortcut.
%# store breakpoints
tmp = dbstatus;
save('tmp.mat','tmp')
%# clear all
close all
clear classes %# clears even more than clear all
clc
%# reload breakpoints
load('tmp.mat')
dbstop(tmp)
%# clean up
clear tmp
delete('tmp.mat')
回答2:
clear all is a heavy hammer. For example, it also dumps all the parsed MATLAB code already in memory. A simple clear or one of the other options is usually a better choice and will not wipe your breakpoints.
回答3:
I had the same issue : after running my code, all breakpoints were deleted. I finally found that you could restore your last breakpoints by clicking on "Set / clear breakpoints" (F12 keypad).
来源:https://stackoverflow.com/questions/12657219/how-to-restore-breakpoints-in-matlab-after-clear-all