I am looking for a way to access variables from other workspaces, in particular the workspace from which the current function is called.
I know how to do it in the simple case:
% Get a variable called `x` from the base workspace
x = evalin('base', 'x');
However, think of a situation where my function myFun, is called by many different functions (which I cannot edit). And I just know that each of them will have a variable x.
Now, how would I be able to see the variable x from the workspace in which myFun is called?
So I guess the key point in my question is:
How can I programmatically navigate to the above workspace?
Here is how it can be done manually:
- Set a breakpoint
- Once the breakpoint is hit use
dbup - Find x and look at it (or do something with it (with
evalinorsave/loadfor example) - Hit f5