Main Content

mxGetPr (Fortran)

(Not recommended) Real data elements in mxDOUBLE_CLASS array

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

Fortran Syntax

#include "fintrf.h"
mwPointer mxGetPr(pm)
mwPointer 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 mwPointer.

Output Arguments

expand all

Pointer to the data array within an mxArray, specified as mwPointer. The data in the output argument depends on which version of the Fortran 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 0.

If pm is 0, then the function returns 0.

Version History

Introduced before R2006a

expand all

R2018b: 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 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.