Deletes variables including memory mapped files. Usage: SurfStatDelete( variable_list [, qualifiers] ); variable_list = comma-delimited list of quoted strings: 'var1', 'var2', ..., 'varN'. You can use the wildcard character * to delete variables that match a pattern. For example, SurfStatDelete('A*') deletes all variables in the current workspace that start with A. If a variable is a memory map, then the mapped file is also deleted. To clean up everything, use SurfStatDelete with no arguments (you will be prompted to confirm). It is a good idea to do this before exiting MATLAB, otherwise memory mapped files will not be deleted. qualifiers = those variables in variable_list that meet all qualifications specified in qualifiers. See "help who" for a list.
0001 function SurfStatDelete( varargin ); 0002 0003 %Deletes variables including memory mapped files. 0004 % 0005 % Usage: SurfStatDelete( variable_list [, qualifiers] ); 0006 % 0007 % variable_list = comma-delimited list of quoted strings: 'var1', 'var2', 0008 % ..., 'varN'. You can use the wildcard character * to delete variables 0009 % that match a pattern. For example, SurfStatDelete('A*') deletes all 0010 % variables in the current workspace that start with A. 0011 % 0012 % If a variable is a memory map, then the mapped file is also deleted. 0013 % 0014 % To clean up everything, use SurfStatDelete with no arguments (you will be 0015 % prompted to confirm). It is a good idea to do this before exiting MATLAB, 0016 % otherwise memory mapped files will not be deleted. 0017 % 0018 % qualifiers = those variables in variable_list that meet all 0019 % qualifications specified in qualifiers. See "help who" for a list. 0020 0021 if nargin==0 0022 reply=input('Are you sure you want to delete everything? Y/N [Y]: ', 's'); 0023 if isempty(reply) 0024 reply='Y'; 0025 end 0026 if ~strcmp(reply,'Y') 0027 return 0028 end 0029 end 0030 if nargin==0 0031 w=evalin('caller','whos'); 0032 else 0033 s=['''' varargin{1} '''']; 0034 for i=2:nargin 0035 s=[s ' , ''' varargin{i} '''']; 0036 end 0037 w=evalin('caller',['whos(' s ')']); 0038 end 0039 n=length(w); 0040 for i=1:n 0041 isc=false; 0042 if strcmp(w(i).class,'struct') 0043 if evalin('caller',['isfield(' w(i).name ',''coord'')']) 0044 isc=evalin('caller',['isa(' w(i).name '.coord,''memmapfile'')']); 0045 end 0046 end 0047 if strcmp(w(i).class,'memmapfile') | isc 0048 if isc 0049 m=evalin('caller',[w(i).name '.coord']); 0050 else 0051 m=evalin('caller',w(i).name); 0052 end 0053 filename=m.Filename; 0054 evalin('caller',['clear ' w(i).name]); 0055 [pathstr,name,ext]=fileparts(filename); 0056 filenameResid=fullfile(pathstr,['Resid' ext]); 0057 warning off all; 0058 delete(filename); 0059 delete(filenameResid); 0060 warning on all; 0061 if length(dir(pathstr))==2 0062 rmdir(pathstr); 0063 end 0064 else 0065 evalin('caller',['clear ' w(i).name]); 0066 end 0067 end 0068 0069 return 0070 end