MATLAB 8.1 (R2013a) currently does not have the ability to retain breakpoints while clearing all the variables in the workspace after issuing "clear all."
As a workaround, the following example function, clearNoBP, clears all the workspace data without removing the break points.
The functions DBSTATUS and DBSTOP are used to get this functionality.
function clearNoBP(varargin)
s = dbstatus;
options = '';
for i = 1:numel(varargin)
options = [options,',''',varargin{i},''''];
end
evalin('caller',['builtin(''clear''',options,')']);
dbstop(s);
end
The above function records all the current breakpoints, evaluates the built-in CLEAR function only in the caller’s workspace and re-sets all the breakpoints.
In order to use clear allowing the breakpoints to remain, execute the following command in the command window,
Also, refer to the following documentation link to see all the available input options with the CLEAR function.
Best Answer