Determining variable scope, existence, and value from a called function
What I want to do is to call a "wrapper()" function from the MATLAB command window that:
1. determines if "fea" is in the MATLAB 'base' variable workspace.
2 if not, then calls a function to export it - the same as FEATool-->File-->Export FEA struct to MATLAB.
3. then (since it now must exist), obtain "fea" from the base workspace and assign it to "local_fea". (local_fea = fea;)
4. finally call "my_function (local_fea);"
[Note: I would just call "my_function (fea)" and then from within "my_function" see if "fea" exists using exist ('fea', 'var'), bit the call, "my_function (fea)", is refused if "fea" does not exist in the 'base' workspace.]
I am trying to make use of things like "exist" and "evalin" but so far success eludes me...