Main Content

mxCreateDoubleMatrix (C)

2-D, double-precision, floating-point array

C Syntax

#include "matrix.h"
mxArray *mxCreateDoubleMatrix(mwSize m, mwSize n, mxComplexity ComplexFlag);


Use mxCreateDoubleMatrix to create an m-by-n mxArray.

Call mxDestroyArray when you finish using the mxArray. The mxDestroyArray function deallocates the mxArray and its associated real and imaginary elements.

Input Arguments

expand all

Number of rows, specified as mwSize.

Number of columns, specified as mwSize.

Complex array indicator, specified as an mxComplexity value.

For applications built with the mex -R2018a command, the function initializes each data element to 0.

For all other mex release-specific build options, the function sets each element in the pr array. If ComplexFlag is mxCOMPLEX, then the function sets the pi array to 0.

Output Arguments

expand all

Pointer to an mxArray of type mxDouble, specified as mxArray *.

The function is unsuccessful when there is not enough free heap space to create the mxArray.

  • MEX file — Function terminates the MEX file and returns control to the MATLAB® prompt.

  • Standalone (non-MEX file) application — Function returns NULL.


See these examples in matlabroot/extern/examples/refbook:

Version History

Introduced before R2006a