-
Notifications
You must be signed in to change notification settings - Fork 2
/
dsclear.m
executable file
·32 lines (31 loc) · 1015 Bytes
/
dsclear.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
% Author: Carl Doersch (cdoersch at cs dot cmu dot edu)
%
% clear a variable from memory, but unlike dsdelete, do not
% get rid of any copies that have been saved to disk.
% allmatchstr can be an absolute or relative path; *-wildcards
% and braces are understood.
function dsclear(allmatchstr)
global ds;
if(nargin<1)
allmatchstr='ds.*';
end
[allmatchstr brakidx]=dssplitmatchstr(allmatchstr);
matchstrs=dsexpandpath(allmatchstr);
for(i=1:numel(matchstrs))
%[matchstr brakidx]=dssplitmatchstr(matchstrs{i})
matchstr=dsfindvar(matchstrs{i});
if(dsfield(matchstr))
%matchstr=dsfindvar(matchstr);
[bkidxstr]=dsrefstring(eval(['size(' matchstr ')']),brakidx,0);
if(~isempty(bkidxstr))
eval([matchstr bkidxstr '={[]};']);
else
dotpos=find(matchstr=='.');
dotpos=dotpos(end);
parent=matchstr(1:(dotpos-1));
child=matchstr((dotpos+1):end);
eval([parent '=rmfield(' parent ',''' child ''')']);
end
end
end
end