Using the C++ Math Library    

Numeric Arrays

The MATLAB C++ Math Library includes routines to create and manipulate numeric arrays. Numeric arrays are the fundamental MATLAB array type. MATLAB supports other numeric array types, such as uint8; however, these data types are only used for importing and exporting image data.

The following table lists the MATLAB C++ Math Library routines to create numeric arrays and perform some basic tasks with them. The sections that follow provide more detail about using these routines. For more detailed information about using numeric arrays, see Using MATLAB. For more detailed information about any of the library routines, see the online MATLAB C++ Math Library Reference.

Table 3-1: Numeric Array Routines 
To ...
Use ...
Create an uninitialized array.
mwArray default constructor:   mwArray A;
Create an empty ([]) array.
empty()
Create an initialized scalar (1-by-1) array from a double precision floating point number.
mwArray scalar constructor:   mwArray(double)
Create an initialized scalar (1-by-1) array from an integer.
mwArray scalar constructor:
  mwArray(int)
Create an initialized m-by-n array (matrix) from double, integer, or unsigned short data.
mwArray matrix constructors:
  mwArray(int, int,
           double*, double*)

  mwArray(int, int,
           int*, int*)

  mwArray(int, int,
           unsigned short*,

           unsigned short*)
Copy an existing mwArray object.
mwArray copy constructor:
  mwArray( mxArray *)
Copy an existing mxArray data type
(returned by a MATLAB C Math Library routine or MATLAB API routine.)
mwArray copy constructor:
  mwArray(const mwArray&)
Create a 1-by-n integer ramp.
mwArray ramp constructor:
  mwArray(int, int, int)
Create an mwArray from a subarray (used in indexing.)
mwArray subarray constructor:
  mwArray(const mwSubArray&)
Create an m-by-n array by concatenating existing arrays
horzcat()
vertcat()
Create an array with more than two dimensions (m-by-n-by-p-by...)
cat()
or by using assignment

Create an array with more than two dimensions (m-by-n-by-p-by...) of ones, zeros, or random numbers.
ones()
zeros()
rand(), randn()
Create an identity matrix or magic square.
eye()
magic()


 MATLAB Array C++ Object Creating Numeric Arrays