From: Aino on
Hi all,

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

Thanks,
Aino
From: Sean on
"Aino" <aino.tietavainen(a)removeThis.helsinki.fi> wrote in message <i43t9g$35k$1(a)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.
From: Tom Bryan on
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