MATLAB Application Program Interface Reference | Help Desk |
mexGetMatrixPtr
Get the pointer to anmxArray
in the caller's workspace
integer*4 function mexGetMatrixPtr(name) character*(*) nameA pointer to an
mxArray
owned by MATLAB.
name
Name of mxArray
to get from caller's workspace.
mexGetMatrixPtr
returns a pointer to the mxArray
with the specified name in the workspace local to the calling function. It allows you to read or modify variables in the MATLAB workspace directly from a MEX-file.
Do not free or reallocate the memory associated with any part of an mxArray
obtained with the mexGetMatrixPtr
function, including the real part, imaginary part, and sparse structure. mxArrays
obtained with this function are managed by MATLAB's own internal mechanisms and MATLAB will crash immediately if you change them.
mexGetMatrixPtr
is meant to be used to read values from an mxArray
in the workspace or to change those values, provided the mxArray
remains the same size, complexity, and sparsity.
To get the pointer of a global variable that is not defined as global by the calling function, first declare it global with a call of the form mexEvalString("global varname")
.