Clear all except some?

  • Follow


Hi all,

how can I clear all the variables in my Workspace except some chosen ones?

Thanks,
Aino
0
Reply Aino 8/13/2010 4:53:04 PM

"Aino" <aino.tietavainen@removeThis.helsinki.fi> wrote in message <i43t9g$35k$1@fred.mathworks.com>...
> Hi all,
> 
> how can I clear all the variables in my Workspace except some chosen ones?
> 
> Thanks,
> Aino

clear variables you do not want
or find keep (et al) on the FEX.  It's a very useful function to have.
0
Reply Sean 8/13/2010 5:04:05 PM


On 8/13/10 12:53 PM, Aino wrote:
> Hi all,
>
> how can I clear all the variables in my Workspace except some chosen ones?
>
> Thanks,
> Aino

Use

   clearvars -except ...

Here's an example:

 >> a=1;b=2;c=3;d=4;e=5;f=6;
 >> whos
   Name      Size            Bytes  Class     Attributes

   a         1x1                 8  double
   b         1x1                 8  double
   c         1x1                 8  double
   d         1x1                 8  double
   e         1x1                 8  double
   f         1x1                 8  double

 >> clearvars -except c f
 >> whos
   Name      Size            Bytes  Class     Attributes

   c         1x1                 8  double
   f         1x1                 8  double

Here's the reference page:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/clearvars.html

Best wishes,
Tom
1
Reply Tom 8/13/2010 6:23:02 PM

Thank you all! 

-Aino

Tom Bryan <tom.bryan@mathworks.com> wrote in message <i442i6$sh4$1@fred.mathworks.com>...
> On 8/13/10 12:53 PM, Aino wrote:
> > Hi all,
> >
> > how can I clear all the variables in my Workspace except some chosen ones?
> >
> > Thanks,
> > Aino
> 
> Use
> 
>    clearvars -except ...
> 
> Here's an example:
> 
>  >> a=1;b=2;c=3;d=4;e=5;f=6;
>  >> whos
>    Name      Size            Bytes  Class     Attributes
> 
>    a         1x1                 8  double
>    b         1x1                 8  double
>    c         1x1                 8  double
>    d         1x1                 8  double
>    e         1x1                 8  double
>    f         1x1                 8  double
> 
>  >> clearvars -except c f
>  >> whos
>    Name      Size            Bytes  Class     Attributes
> 
>    c         1x1                 8  double
>    f         1x1                 8  double
> 
> Here's the reference page:
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/clearvars.html
> 
> Best wishes,
> Tom
0
Reply Aino 8/14/2010 11:42:04 AM

3 Replies
2111 Views

(page loaded in 0.054 seconds)

Similiar Articles:













7/22/2012 1:55:58 AM


Reply: