Proper use of clearvars in MATLAB

The clearvars function contains the instructions presented here .

So to speak, I have a set of variables,

  a, b, c, d 

and I want to clear these variables except d , I have 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?

+7
source share
2 answers

This works: clearvars '*' -except d

Matlab should have a problem converting * to a string when it is on its own. It works great with both a* and *a , but not * .

In addition, this works:

 clearvars('*', '-except', 'd') 
+7
source

The * character is not needed.

+5
source

All Articles