From: AMK on
Hi,
How does one clear variables from a workspace when called from within a function? I have this line in the function

% Clean up the workspace
clear data k l u a b data textdata

and it's not clearing anything. Any suggestions?

Thanks,
From: dpb on
AMK wrote:
> Hi,
> How does one clear variables from a workspace when called from within
> a function? I have this line in the function
>
> % Clean up the workspace
> clear data k l u a b data textdata
>
> and it's not clearing anything. Any suggestions?

That's certainly not as documented. What do you have to suggest it doesn't?

--
From: TideMan on
On Feb 19, 11:47 am, dpb <n...(a)non.net> wrote:
> AMK wrote:
> > Hi,
> > How does one clear variables from a workspace when called from within
> > a function? I have this line in the function
>
> > % Clean up the workspace
> > clear data k l u a b data textdata
>
> > and it's not clearing anything.  Any suggestions?
>
> That's certainly not as documented.  What do you have to suggest it doesn't?
>
> --

So, you're sitting in a function and these variables exist where?
In the function or in the workspace?
Because if they are in the workspace, you have no access to them from
within the function.
You can only clear them from the function's workspace, not the command
window workspace.

Well, that's the only way I can interpret what you have shown us.
From: AMK on
Well okay, maybe I've got the command in the wrong m.file. I create these variables in one m.file (Nu.m) that defines the variables, and calls the m.file NuCreate.m, which is a function I created. You suggest you can't clear a workspace from within a function? That certainly appears to be the case. So I need to put the "clear" command in the file that defines the variables (Nu.m)?

thanks
From: AMK on
So obviously that will work, but I didn't know you couldn't (or the reason why)you can't clear workspace variables from within a function.