Copy of variable from specified workspace
#include "mex.h" mxArray *mexGetVariable(const char *workspace, const char *varname);
To write MEX functions using modern C++ features and the MATLAB Data API for C++, see Write C++ Functions Callable from MATLAB (MEX Files).
mexGetVariable to get a copy of the specified variable. The
mxArray contains a copy of all the data and characteristics
that the variable had in the other workspace. Modifications to the returned
mxArray do not affect the variable in the workspace unless you
write the copy back to the workspace with
mxDestroyArray to destroy the
created by this routine when you are finished with it.
workspace — Workspace
mexGetVariable searches for
varname, specified as
The possible values are:
Search for the variable in the base workspace.
Search for the variable in the caller workspace.
Search for the variable in the global workspace.
varname — Variable name
Name of the variable to copy, specified as
var — Copy of variable
Copy of variable, specified as
mxArray*. The function
NULL on failure. A common cause of failure is
specifying a variable that is not currently in the workspace. Perhaps the
variable was in the workspace at one time but has since been cleared.
See these examples in