Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using clearvars correctly in MATLAB

Tags:

matlab

The function clearvars has the instructions presented here.

So say I have a set of variables,

 a, b, c, d

and I want to clear these variables except for d I should be able to do this:

clearvars * -except d

but I get the following error:

 clearvars * -except d
                |
Error: Unexpected MATLAB expression.

What is the reason for this?

like image 448
Fantastic Mr Fox Avatar asked Sep 13 '12 00:09

Fantastic Mr Fox


1 Answers

This works: clearvars '*' -except d

Matlab must have a problem converting * into a string when it's on its own. It's fine with both a* and *a, but not *.

Also, this works:

clearvars('*', '-except', 'd')
like image 105
Evgeni Sergeev Avatar answered Nov 05 '22 01:11

Evgeni Sergeev