help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: clear all variables except specific ones


From: Martin Weiser
Subject: Re: clear all variables except specific ones
Date: Tue, 15 Aug 2017 01:17:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 14.8.2017 20:53, Mike Miller wrote:
On Sat, Aug 12, 2017 at 06:30:29 -0700, dariodematties wrote:
How can I clear all variables except a specific subset from them?

Probably a couple ways. Here is how you can get a cell array of names of
variables in your workspace:

    v = whos;
    names = {v.name};

or the uglier shortcut

    names = {[whos].name};

From there you can iterate over the list of variable names and clear or
not clear each one.

You could also save the variables you like to a file, clear all, and
load the file back into your workspace.



_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave

Hi,

Would not be something like:

clear -x the_one_i_need

or

clear -x *[0-9] #clear those that do not end by digit

more elegant?

Of course, the usability of the above stands and fails with the length of the list you wish to retain or upon your ability to find the matching pattern.

See:
https://www.gnu.org/software/octave/doc/interpreter/Status-of-Variables.html#index-clear

Best,
Martin W.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]