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 Version History.

C Syntax

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

Description

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

R2018a: Do not use separate complex API

Use the mxGetDoubles function in the interleaved complex API for real input arrays of type mxDOUBLE_CLASS. Use mxGetComplexDoubles for complex input arrays of type mxDOUBLE_CLASS. These functions validate the type and complexity of the input.

MathWorks recommends that you create MEX files and update existing MEX files using 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.