필터 지우기
필터 지우기

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개)

José-Luis
José-Luis 2012년 11월 12일
This sounds like a job for keep4.
  댓글 수: 3
José-Luis
José-Luis 2012년 11월 12일
Or if you prefer the simpler syntax

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by