External Interfaces Reference Previous page   Next Page
mxCreateNumericMatrix

Create numeric matrix and initialize data elements to 0

Fortran Syntax

Arguments

m
   The desired number of rows.

n
   The desired number of columns.

classid
   A numerical identifier that represents a particular MATLAB class. Use the function, mxClassIDFromClassName, to derive the classid value from a class name character array.

The classid tells MATLAB how you want the numerical array data to be represented in memory. For example, specifying the int32 class causes each piece of numerical data in the mxArray to be represented as a 32-bit signed integer.

mxCreateNumericMatrix accepts any of the MATLAB signed numeric classes, shown to the left in the table below.

ComplexFlag
   If the data you plan to put into the mxArray has no imaginary components, specify 0. If the data has some imaginary components, specify 1.

Returns

A pointer to the created mxArray, if successful. mxCreateNumericMatrix is unsuccessful if there is not enough free heap space to create the mxArray. If mxCreateNumericMatrix is unsuccessful in a MEX-file, the MEX-file prints an Out of Memory message, terminates, and control returns to the MATLAB prompt. If mxCreateNumericMatrix is unsuccessful in a stand-alone (nonMEX-file) application, mxCreateNumericMatrix returns 0.

Description

Call mxCreateNumericMatrix to create an two-dimensional mxArray in which all data elements have the numeric data type specified by classid. After creating the mxArray, mxCreateNumericMatrix initializes all its real data elements to 0. If ComplexFlag is set to 1, mxCreateNumericMatrix also initializes all its imaginary data elements to 0. mxCreateNumericMatrix allocates dynamic memory to store the created mxArray. When you finish using the mxArray, call mxDestroyArray to destroy it.

The following table shows the Fortran data types that are equivalent to MATLAB classes. Use these as shown in the example below.

MATLAB Class Name
Fortran Type
int8
BYTE
int16
INTEGER*2
int32
INTEGER*4
single
REAL*4
double
REAL*8
single, with imaginary components
COMPLEX*8
double, with imaginary components
COMPLEX*16

Example

To create a 4-by-3 matrix of REAL*4 elements having no imaginary components, use

See Also

mxCreateDoubleMatrix, mxCreateNumericArray


Previous page  mxCreateNumericArray mxCreateScalarDouble Next page

© 1994-2005 The MathWorks, Inc.