Clear all variables except a specified variable in matlab

533 views
Skip to first unread message

Haifeng Gong

unread,
Jun 2, 2005, 2:28:33 AM6/2/05
to math...@googlegroups.com
allvars = whos;
for ii=1:length(allvars)
    if( ~strcmp(allvars(ii).name , 'vartokeep' )  && ~( strcmp(allvars(ii).name ,'allvars')) )
        clear(allvars(ii).name);
    end
end
clear allvars
clear ii
whos
--
:-)
Reply all
Reply to author
Forward
0 new messages