From: Husam Aldahiyat on
Hello,
What I mean is, how can I transfer the workspace and all its variables (including loop counters and toc) from a nested function, for example, and make it available in another function?
From: Walter Roberson on
Husam Aldahiyat wrote:

> What I mean is, how can I transfer the workspace and all its variables
> (including loop counters and toc) from a nested function, for example,
> and make it available in another function?

Do you need only read access, or read/write access?

Is it acceptable to have one or more "accessor" functions that need to be
called to get or set the values, or is your expectation that the workspace
will be "shared" and that you will be able to access the variables by name,
something along the lines of:

%FizzBoom is a variable in the nested function

import_the_workspace();

%display what FizzBoom is currently in the nested function without
%specifically importing it
disp(FizzBoom);

pause(0.5);
%display the updated FizzBoom from the nested function without
%specifically asking for it again

disp(FizzBoom);

%if FizzBoom is a loop counter of an active loop, then if you update its
%value, is it important that the loop skip (or go back) to the new value?
%Keeping in mind that if you try to assign a new value to a loop counter from
%within matlab, that at the beginning of the next loop trip the change in
%value would be ignored and the next loop value in normal sequence would be
%used -- so do you need access to the *internal* variables to be able to
%mess with them?

FizzBoom = FizzBoom + 23;


You will likely not be able to access the toc() value: the start time is saved
by tic to an unnamed location.


From: Matt J on
"Husam Aldahiyat" <numandina(a)gmail.com> wrote in message <hnebbp$eof$1(a)fred.mathworks.com>...
> Hello,
> What I mean is, how can I transfer the workspace and all its variables (including loop counters and toc) from a nested function, for example, and make it available in another function?
=================

You can return a function handle fhandle to the nested function. Then, if I've understood what you're after, you can use the function below.

function StateStruct=wspace(fhandle)
%Get the workspace of a function handle
%
% StateStruct=wspace(fhandle)
%
%For now, very rudimentary.


z=functions(fhandle);
StateStruct=z.workspace{1};
From: jojo on
i bet you have a big ''youknow


---
frmsrcurl: http://compgroups.net/comp.soft-sys.matlab/How-can-I-create-my-own-workspace
From: Husam Aldahiyat on
I don't want to edit the loop counter, and toc isn't very important actually, but I want to obtain which variables were used and make new variables with the exact same name in my new workspace/function, which have the same values as the previous variables. Also, this needs to be general (no passing on information from one function to another).

I think I'm aiming too high but maybe there's something out there?

So far my only option is using image processing and some long techniques to read the workspace window and the values inside.