Revision 495
(checked in by cbc, 12 years ago)
|
Initial import of Stark code.
|
Line | |
---|
1 |
function keep(varargin); |
---|
2 |
%KEEP keeps the base workspace variables of your choice and clear the rest. |
---|
3 |
% |
---|
4 |
% CALL: keep var1 var2 var3 ... |
---|
5 |
% |
---|
6 |
% |
---|
7 |
% Yoram Tal 5/7/98 yoramtal@internet-zahav.net |
---|
8 |
% MATLAB version 5.2 |
---|
9 |
% Based on a program by Xiaoning (David) Yang |
---|
10 |
% 15/9/99 Bug fix - empty delete sring (due to Hyrum D Johnson) |
---|
11 |
% |
---|
12 |
% 29 Mar 2000 Catherine R. Edwards - Feature added to keep all globals |
---|
13 |
% |
---|
14 |
|
---|
15 |
% Find variables in base workspace |
---|
16 |
wh = evalin('base','who'); |
---|
17 |
|
---|
18 |
% Remove variables in the "keep" list |
---|
19 |
del = setdiff(wh,varargin); |
---|
20 |
|
---|
21 |
% Keep all global variables |
---|
22 |
isglo=nan*ones(1,length(del)); |
---|
23 |
for i=1:length(del) |
---|
24 |
isglo(i)=evalin('base',['isglobal(' char(wh(i)) ')']); |
---|
25 |
end |
---|
26 |
del(find(isglo==1))=[]; |
---|
27 |
|
---|
28 |
% Nothing to remove - return |
---|
29 |
if isempty(del), |
---|
30 |
return; |
---|
31 |
end |
---|
32 |
|
---|
33 |
% Construct the clearing command string |
---|
34 |
str=blank(column([repmat(',''',length(del),1),char(del),repmat('''',length(del),1)]')'); |
---|
35 |
|
---|
36 |
% Clear |
---|
37 |
evalin('base',['clear(',str(2:end),');']) |
---|