Filter löschen
Filter löschen

How to 'who' the global workspace to a variable in a function ?

1 Ansicht (letzte 30 Tage)
Hi,
I'm trying to do a "clear all but" function, i.e. clear all variables in the workplace except those who are specified : function [ ] = clearAllBut( var1, var2 ...)
I was thinking about getting the workspace variables names in a cell with : A = who('global') but it doesn't work since the call of who is within a function and retrieves the local workspace (which is empty because it is the first thing I do in my function).
Is there a way to really retrieve the global workspace variable names ?
Thank you for your help
Léo.

Akzeptierte Antwort

Matt J
Matt J am 12 Nov. 2012
I don't see how retrieving the global workspace variables helps you. To clear all variables excluding some set, do
clearvars -except A B C
etc...

Weitere Antworten (1)

José-Luis
José-Luis am 12 Nov. 2012
This sounds like a job for keep4.
  3 Kommentare
José-Luis
José-Luis am 12 Nov. 2012
Or if you prefer the simpler syntax

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by