| External Interfaces Reference | ![]() |
Copy mxArray from MEX-function into specified workspace
C Syntax
#include "mex.h"
int mexPutVariable(const char *workspace, const char *var_name,
const mxArray *array_ptr);
Arguments
workspace
Specifies the scope of the array that you are copying. The possible values are
base |
Copy mxArray to the base workspace |
caller |
Copy mxArray to the caller's workspace |
global |
Copy mxArray to the list of global variables |
var_name
Name given to the mxArray in the workspace.
array_ptr
Pointer to the mxArray.
Returns
0 on success; 1 on failure. A possible cause of failure is that array_ptr is NULL.
Description
Call mexPutVariable to copy the mxArray, at pointer array_ptr, from your MEX-function into the specified workspace. MATLAB gives the name, var_name, to the copied mxArray in the receiving workspace.
mexPutVariable makes the array accessible to other entities, such as MATLAB, M-files or other MEX-functions.
If a variable of the same name already 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
and you call mexPutVariable to copy Peaches into the same workspace:
Then the old value of Peaches disappears and is replaced by the value passed in by mexPutVariable.
Examples
See mexgetarray.c in the mex subdirectory of the examples directory.
See Also
| mexPutMatrix (Obsolete) | mexSet | ![]() |
© 1994-2005 The MathWorks, Inc.