Is there a way to clear all persistent variables in MATLAB functions, while keeping the breakpoints in the corresponding function files?
clear all;
and
clear functions;
both kill the breakpoints.
Is there a way to clear all persistent variables in MATLAB functions, while keeping the breakpoints in the corresponding function files?
clear all;
and
clear functions;
both kill the breakpoints.
Unfortunately, clearing persistent variables also clears breakpoints, but there is a workaround.
After setting the breakpoints you want to retain, use the dbstatus
function to get a structure containing those breakpoints and then save that structure to a MAT file. After clearing variables, you can then reload those variables by loading the MAT file and using dbstop. Following is an example of performing this sequence of operations:
s=dbstatus;
save('myBreakpoints.mat', 's');
clear all
load('myBreakpoints.mat');
dbstop(s);
If there is data in @directories, you can still use the method that RTBarnard proposes
s=dbstatus('-completenames');
save('myBreakpoints.mat','s');
%# if you're clearing, you may as well just clear everything
%# note that if there is stuff stored inside figures (e.g. as callbacks), not all of
%# it may be removed, so you may have to 'close all' as well
clear classes
load('myBreakpoints.mat')
dbstop(s);
%# do some cleanup
clear s
delete('myBreakpoints.mat')