mexPutVariable (C)
Array from MEX function into specified workspace
C Syntax
#include "mex.h" int mexPutVariable(const char *workspace, const char *varname, const mxArray *pm);
Description
Note
To write MEX functions using modern C++ features and the MATLAB Data API for C++, see Write C++ Functions Callable from MATLAB (MEX Files).
Call mexPutVariable to copy the mxArray, at
pointer pm, from your MEX function into the specified workspace.
MATLAB® assigns varname to the mxArray
copied in the workspace.
mexPutVariable makes the array accessible to other entities, such
as MATLAB, user-defined functions, or other MEX functions.
If a variable of the same name exists in the specified workspace,
mexPutVariable overwrites the previous contents of the variable
with the contents of the new mxArray. For example, suppose the
MATLAB workspace defines variable Peaches as:
Peaches 1 2 3 4
and you call mexPutVariable to copy Peaches
into the same workspace:
mexPutVariable("base", "Peaches", pm)The value passed by mexPutVariable replaces the old value of
Peaches.
Input Arguments
Output Arguments
Examples
To open an example, type:
edit([fullfile(matlabroot,"extern","examples","mex","filename")]);
where filename is:
Version History
Introduced before R2006a