Main Content

mxGetPr (C)

(Not recommended) Real data elements in mxDOUBLE_CLASS array

mxGetPr is not recommended. Use mxGetDoubles or mxGetComplexDoubles instead. For more information, see Compatibility Considerations.

C Syntax

#include "matrix.h"
mxDouble *mxGetPr(const mxArray *pm);


Use mxGetPr on real arrays of type mxDOUBLE_CLASS only. For other numeric mxArray types, use Typed Data Access in C MEX Files functions. For complex arrays, see the description for output argument dt.

Call mxIsDouble to validate the mxArray type. Call mxIsComplex to determine whether the data is real.

Input Arguments

expand all

Pointer to a MATLAB array of type mxDOUBLE_CLASS, specified as mxArray *.

Output Arguments

expand all

Pointer to the data array within an mxArray, specified as mxDouble *. The data in the output argument depends on which version of the C Matrix API you use:

  • If you build with the separate complex API (mex -R2017b option), then the function returns a pointer to the first mxDouble element of the real part of the data.

  • If you build with the interleaved complex API (mex -R2018a option) and pm is complex, then the function terminates the MEX file and returns control to the MATLAB prompt. In a non-MEX file application, the function returns NULL.

If pm is NULL, then the function returns NULL.

Version History

Introduced before R2006a

expand all

Not recommended starting in R2018a

Errors starting in R2018a