フィルターのクリア

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

1 回表示 (過去 30 日間)
Léonard Roussel
Léonard Roussel 2012 年 11 月 12 日
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.

採用された回答

Matt J
Matt J 2012 年 11 月 12 日
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...
  1 件のコメント
Léonard Roussel
Léonard Roussel 2012 年 11 月 12 日
Oh I didn't know it existed. Thank you !

サインインしてコメントする。

その他の回答 (1 件)

José-Luis
José-Luis 2012 年 11 月 12 日
This sounds like a job for keep4.
  3 件のコメント
Léonard Roussel
Léonard Roussel 2012 年 11 月 12 日
Thanks !
José-Luis
José-Luis 2012 年 11 月 12 日
Or if you prefer the simpler syntax

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by