Code covered by the BSD License  

Highlights from
clear except...

3.85714

3.9 | 7 ratings Rate this file 13 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
clear keep erase(4), fex
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
25 Apr 2012 Piyush

thanks for the file!!

14 Jan 2012 Gijs  
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.

10 Dec 2008 Federico Ang

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

17 Jun 2008 William Vidal

You've saved my project...

14 Apr 2008 fex observer

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

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 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.

Updates
04 Jun 2008

updated to enable wildcards

Contact us