Inside of an function I want to do assignin(ws, 'var', val)
, but at this point I don't know the workspace ws, which is currently displayed in the workspace window inside the matlab window. I am looking for a statement which replaces my ws
in the statement above.
Probably a simple and a frequently asked question, but i didn't find an answer.
What you seem to want is do an assignin
in the current workspace. But this is trivial in MATLAB, because is the basic assignment:
var = val;
The other two accessible workspaces via the ws
parameter are:
'base'
, which is the base workspace (all the scripts will create their variables in it);
'caller'
, which is the workspace of the calling function (this workspace is created every time you enter a function, and destroyed when exiting the function), or the global workspace if called from a script.