2-D numeric matrix
#include "matrix.h" mxArray *mxCreateNumericMatrix(mwSize m, mwSize n, mxClassID classid, mxComplexity ComplexFlag);
mwPointer mxCreateNumericMatrix(m, n, classid, ComplexFlag) mwSize m, n integer*4 classid, ComplexFlag
m
Number of rows
n
Number of columns
classid
Identifier for the class of the array, which determines the
way the numerical data is represented in memory. For example, specifying mxINT16_CLASS
in
C causes each piece of numerical data in the mxArray
to
be represented as a 16-bit signed integer. In Fortran, use the function mxClassIDFromClassName
to
derive the classid
value from a MATLAB® class
name.
ComplexFlag
If the mxArray
you are creating is to contain
imaginary data, set ComplexFlag
to mxCOMPLEX
in C (1
in Fortran). Otherwise, set ComplexFlag
to mxREAL
in C (0
in Fortran).
Pointer to the created mxArray
,
if successful. If unsuccessful in a standalone (non-MEX file) application,
returns NULL
in C (0
in Fortran).
If unsuccessful in a MEX file, the MEX file terminates and
returns control to the MATLAB prompt. The function is unsuccessful
when there is not enough free heap space to create the mxArray
.
Call mxCreateNumericMatrix
to create a
2-D 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
equals mxCOMPLEX
in
C (1
in Fortran), 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 C classid
values
and the Fortran data types that are equivalent to MATLAB classes.
MATLAB Class Name | C | Fortran Type |
---|---|---|
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
|
|
See the
following examples in matlabroot
/extern/examples/refbook
.
The following 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)
mxClassId
, mxClassIdFromClassName
, mxComplexity
, mxDestroyArray
, mxCreateUninitNumericMatrix
, mxCreateNumericArray