I know clear all deletes them all but I need to keep one of them.
Thanks
Ak6<k]eihkh*aca{dIppd#ldkak]lijq{{]u_kj]{{]{_^r]gp]U#e{{^qa
clearvars -except v1 v2 ... clears all variables except for those specified following the -except flag. Use the wildcard character '*' in a variable name to exclude variables that match a pattern from being cleared. clearvars -except X* clears all the variables in the current workspace, except for those that start with X, for instance.
k{{_l{A{ueUpah6]ajhdjdqie{kk#^]qcga{p^#*{]{k]airIp]dkk_]<]l
> I have a code that creates many variables and at each iteration I want to clear all the variables except for one or two. Is this possible without specifying clear A, clear B and so on for every variable?
Let the names of all variables, which should be cleared, start with a specific string, e.g.
"away_". Then "clear away_*" deletes them from memory.
By the way: clearing and recreation of variables is very time consuming. It could be more effective to use a cell instead of a cloud of variables.
Good luck, Jan Simon
You're correct, CLEARVARS was introduced in release R2008a.
http://www.mathworks.com/access/helpdesk/help/techdoc/rn/brjk1q5-1.html
--
Steve Lord
sl...@mathworks.com