No BSD License  

Highlights from
KEEPDB

from KEEPDB by Alex Bar-Guy
KEEPDB is the same as CLEAR but it does not remove debugging breakpoints.

keepdb( filename )
function keepdb( filename )
% KEEPDB (or KEEPDB ALL) is the same as CLEAR ALL but it does not remove 
%                        debugging breakpoints 
% KEEPDB FUN is the same as CLEAR FUN but it does not remove
%            debugging breakpoints from the specified function

% Version 1.0
% Alex Bur-Guy, October 2005
% Any comments and suggestions please send to:
%    alex@wavion.co.il

if nargin < 1
     filename = 'all';
end
if strcmp( filename, 'all' )
     s = dbstatus;
else
     if exist( filename ) ~= 2
          fprintf( '\n M-function %s not found. \n', filename );
          return;
     end
     s = dbstatus( filename );
end
setpref( 'dbstatus_', 'last', s );
evalin('base', ['clear ' filename ]);
s = getpref( 'dbstatus_', 'last' );
rmpref( 'dbstatus_', 'last' );
rmpref( 'dbstatus_' ); 
for ii = 1 : length(s)
     if isempty( s(ii).name ) & ~isempty( s(ii).cond )
          evalStrIni = [ 'dbstop if ' s(ii).cond];
          if isfield( s(ii), 'identifier' )
               for jj = 1 : length( s(ii).identifier ),
                    if ~isempty( s(ii).identifier{jj} ) 
                         evalStr = [ evalStrIni ' ' s(ii).identifier{jj} ];
                    end
                    evalin( 'base', evalStr );
               end
          else
               evalin( 'base', evalStrIni ); 
          end
     elseif ~isempty( s(ii).name ) & isempty( s(ii).cond )
          if str2num( version('-release') ) >= 14, sep = '>'; d=1; else, sep = '('; d=2; end
          for jj = 1 : length( s(ii).line ),
               if ~isempty( findstr(s(ii).name, sep) )
                    evalStr = [ 'dbstop in ''' s(ii).name(1:min(findstr(s(ii).name, sep))-d) ''' at ' num2str(s(ii).line(jj)) ];
               else
                    evalStr = [ 'dbstop in ''' s(ii).name ''' at ' num2str(s(ii).line(jj)) ];                   
               end
               if isfield( s(ii), 'expression' )
                    if ~isempty( s(ii).expression{jj} )
                         evalStr = [ evalStr ' if ' s(ii).expression{jj} ];
                    end
               end
               evalin( 'base', evalStr );
          end
     end
end     

Contact us