save_to_base() copies variables in the workspace of the calling function to the base workspace. This makes it possible to examine a function's internal variables from the Matlab command prompt after the calling function terminates.
If the optional argument "overwrite" is present and has a non-zero value, variables in the workspace of the caller will overwrite variables in the base workspace having the same name. Otherwise, preexisting variables in the base workspace will not be overwritten.
Thank you very, very much. I use this in combination with xlsread1 and xlswrite2, which require Excel to be in de workspace.
Do the job
Thank you for the nice function :)
A small bugfix: instead of "length(nargin)" it has to be just "nargin"
For me it does not work. I have a function that has some variables to save in workspace. I use evali('base',VarName) but that does not work. Just after file execution, all variables disappear from workspace
I found trouble when I had a stray "ans" variable floating around. I got this message:
??? The variable "ans" is undefined.
To avoid trying to copy "ans", I modified save_to_base.m so that the for loop now reads:
for i= 1 : length(variables)
Very nice little function.
Added patch to exclude 'ans' variable.
This file replaces save_variables, and fixes two problems:
- It is no longer necessary to nest the function.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.