Main Content

mxCreateNumericArray (Fortran)

N-D numeric array

Fortran Syntax

#include "fintrf.h"
mwPointer mxCreateNumericArray(ndim, dims, classid, ComplexFlag)
mwSize ndim
mwSize dims(ndim)
integer*4 classid, ComplexFlag

Description

Use mxCreateNumericArray to create an N-dimensional mxArray.

mxCreateNumericArray differs from mxCreateDoubleMatrix as follows:

  • All data elements in mxCreateDoubleMatrix are double-precision, floating-point numbers. The data elements in mxCreateNumericArray can be any numerical type, including different integer precisions.

  • mxCreateDoubleMatrix creates two-dimensional arrays only. mxCreateNumericArray can create arrays of two or more dimensions.

MATLAB® automatically removes any trailing singleton dimensions specified in the dims argument. For example, if ndim equals 5 and dims equals [4 1 7 1 1], then the resulting array has the dimensions 4-by-1-by-7.

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 dimensions, specified as mwSize. If ndim is less than 2, then mxCreateNumericArray sets the number of dimensions to 2.

Dimensions array, specified as an array of mwSize.

Each element in the dimensions array contains the size of the array in that dimension. For example, to create a 5-by-7 array, set dims(1) to 5 and dims(2) to 7.

Usually, the dims array contains ndim elements.

Class identifier, specified as integer*4. classid 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 classid, specified as mwPointer.

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.

Version History

Introduced before R2006a