Code covered by the BSD License  

Highlights from
clear except...

3.66667

3.7 | 6 ratings Rate this file 28 Downloads (last 30 days) File Size: 1.28 KB File ID: #19548

clear except...

by Arnaud Laurent

 

11 Apr 2008 (Updated 04 Jun 2008)

clear workspace except prescribed variables

| Watch this File

File Information
Description

This function clear all variables in the workspace except the variables listed in the function argument.
Example: clearex('var1',var2') will clear all variables in the workspace except var1 and var2.
Note: wildcards (e.g. 'var*') can be used.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
14 Apr 2008 Duane Hanselman

This functionality has been posted to the FEX many times, e.g., keep, keep2, keep3. This functionality also exists as part of MATLAB itself starting with R2008a, i.e.,

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.

14 Apr 2008 Urs (us) Schwarz

yet another one of these KEEP-ers...
note: r2008a (finally) introduces CLEARVARS with these options

clearvars -except v1 v2 ...
clearvars -except -regexp p1 p2 ...
clearvars v1 v2 ... -except -regexp p1 p2 ...
clearvars -regexp p1 p2 ... -except v1 v2 ...

us

14 Apr 2008 fex observer

If these two well-known reviewers tell the truth, you should remove this submission.

17 Jun 2008 William Vidal

You've saved my project...

10 Dec 2008 Federico Ang

not everyone uses r2008a if you people would only realize that...

04 May 2011 Martin Lenz

many users don't have a version like r2008a or newer. this function is also necessary. thank's a lot.

14 Jan 2012 Gijs  
Please login to add a comment or rating.
Updates
04 Jun 2008

updated to enable wildcards

Tag Activity for this File
Tag Applied By Date/Time
clear keep erase Arnaud Laurent 22 Oct 2008 09:57:20
clear keep erase Guisella GacitĂșa 23 Apr 2011 05:34:54
clear keep erase Gijs 14 Jan 2012 09:13:52

Contact us at files@mathworks.com