Main Content

mxCreateNumericMatrix (C)

2-D numeric matrix

C Syntax

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

Description

Use mxCreateNumericMatrix to create a 2-D mxArray. The classid specifies the numeric data type of the elements in the array.

This table shows the C classid values that are equivalent to MATLAB® classes.

MATLAB Class Name

C classid Value

int8

mxINT8_CLASS

uint8

mxUINT8_CLASS

int16

mxINT16_CLASS

uint16

mxUINT16_CLASS

int32

mxINT32_CLASS

uint32

mxUINT32_CLASS

int64

mxINT64_CLASS

uint64

mxUINT64_CLASS

single

mxSINGLE_CLASS

double

mxDOUBLE_CLASS

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.

Class identifier, specified as an mxClassID enumeration. The classid argument determines how the numerical data is represented in memory. For example, mxCreateNumericMatrix stores mxINT16_CLASS values as 16-bit signed integers.

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 classid, specified as mxArray *, if successful.

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.

Examples

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

Version History

Introduced before R2006a