Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Delete a variable in the base workspace from within a function

Subject: Delete a variable in the base workspace from within a function

From: Jonathan L. Liscouët

Date: 15 Sep, 2010 13:34:09

Message: 1 of 3

Hello,

I would like to delete a variable located in the base workspace with a command in a function. I could create this variable throught the command: assignin('base',VarName,VarValue). How can I delete it now?

Example:
-------------------------------------------------------------------------------------------------------------------
function DeleteFcn()
  
VarName = 'abc'; % Define variable name
VarValue = 1.23; % Set variable value
assignin('base', BlockName,BlockData); % Store variable into base workspace
...
??? % Delete variable in base workspace

end
-------------------------------------------------------------------------------------------------------------------

Thanks in advance,

Subject: Delete a variable in the base workspace from within a function

From: Sean

Date: 15 Sep, 2010 13:45:58

Message: 2 of 3

"Jonathan L. Liscouët" <jonathan.liscouet@aero.bombardier.com> wrote in message <i6qi0h$g32$1@fred.mathworks.com>...
> Hello,
>
> I would like to delete a variable located in the base workspace with a command in a function. I could create this variable throught the command: assignin('base',VarName,VarValue). How can I delete it now?
>
> Example:
> -------------------------------------------------------------------------------------------------------------------
> function DeleteFcn()
>
> VarName = 'abc'; % Define variable name
> VarValue = 1.23; % Set variable value
> assignin('base', BlockName,BlockData); % Store variable into base workspace
> ...
> ??? % Delete variable in base workspace
>
> end
> -------------------------------------------------------------------------------------------------------------------
>
> Thanks in advance,


evalin('caller',['clear ',VarName])

-Sean

Subject: Delete a variable in the base workspace from within a function

From: Jonathan L. Liscouët

Date: 15 Sep, 2010 15:26:04

Message: 3 of 3

Excellent!
Thank a lot.

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i6qimm$22f$1@fred.mathworks.com>...
> "Jonathan L. Liscouët" <jonathan.liscouet@aero.bombardier.com> wrote in message <i6qi0h$g32$1@fred.mathworks.com>...
> > Hello,
> >
> > I would like to delete a variable located in the base workspace with a command in a function. I could create this variable throught the command: assignin('base',VarName,VarValue). How can I delete it now?
> >
> > Example:
> > -------------------------------------------------------------------------------------------------------------------
> > function DeleteFcn()
> >
> > VarName = 'abc'; % Define variable name
> > VarValue = 1.23; % Set variable value
> > assignin('base', BlockName,BlockData); % Store variable into base workspace
> > ...
> > ??? % Delete variable in base workspace
> >
> > end
> > -------------------------------------------------------------------------------------------------------------------
> >
> > Thanks in advance,
>
>
> evalin('caller',['clear ',VarName])
>
> -Sean

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us