Main Content

mxCreateNumericMatrix (Fortran)

2-D numeric matrix

Fortran Syntax

#include "fintrf.h"
mwPointer mxCreateNumericMatrix(m, n, classid, ComplexFlag)
mwSize m, n
integer*4 classid, 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 Fortran types that are equivalent to MATLAB® classes.

MATLAB Class Name

Fortran Type

int8

BYTE

int16

INTEGER*2

int32

INTEGER*4

int64

INTEGER*8

single

REAL*4
COMPLEX*8

double

REAL*8
COMPLEX*16

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 integer*4. The classid argument determines how the numerical data is represented in memory. Use the mxClassIdFromClassName function to derive the classid value from a MATLAB class name.

Complex array indicator, specified as an 0 or 1.

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 1, then the function sets the pi array to 0.

Output Arguments

expand all

Pointer to an mxArray of type mxChar, specified as mwPointer, 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 0.

Examples

These Fortran statements create a 4-by-3 matrix of REAL*4 elements having no imaginary components:

C      Create 4x3 mxArray of REAL*4
       mxCreateNumericMatrix(4, 3,
     +                mxClassIDFromClassName('single'), 0)

Version History

Introduced before R2006a