Main Content

mxGetData (C)

Data elements in nonnumeric mxArray

mxGetData is not recommended for numeric arrays. Use typed, data-access functions instead. For more information, see Compatibility Considerations.

C Syntax

#include "matrix.h"
void *mxGetData(const mxArray *pm);


Use mxGetData to get data elements for nonnumeric arrays only.

For numeric arrays, MathWorks recommends that you create MEX files and update existing MEX files to use the typed, data-access functions in the interleaved complex API. For more information, see:

To build the MEX file, call mex with the -R2018a option.

Input Arguments

expand all

Pointer to a nonnumeric MATLAB array, specified as mxArray *.

Output Arguments

expand all

Pointer to the data array within an mxArray, specified as void *. Since void pointers point to a value that has no type, cast the return value to the pointer type that matches the type specified by pm. For information on mapping MATLAB types to their equivalent C types, see mxClassID.

If pm is NULL, then the function returns NULL.

Version History

Introduced before R2006a

expand all