Using the C++ Math Library    

Dimensions and Subscripts in the MATLAB C++ Math Library

The MATLAB C++ Math Library supports N-dimensional standard, cell array, and structure indexing. You use:

The indexing operator () and mwArray::cell() take numeric arguments, one index for each dimension of the array being indexed. mwArray::field() takes the name of the structure field as an argument.

Applying a subscript to an array allows you to:

elements of an array. For example, the two-dimensional indexing expression

applies the subscript (3,1) to A and returns the element at row 3, column 1.  A(9), a one-dimensional indexing expression, returns the ninth element of array A.

An index can be a scalar, a vector, a matrix, or a call to the special function colon().

If you provide arguments to colon(), the subscript specifies a vector. For example, colon(1,10) specifies the vector [ 1 2 3 4 5 6 7 8 9 10 ].

The MATLAB C++ Math Library implements indexing via the interaction of three classes: mwArray, mwIndex, and mwSubArray. mwArray represents the array itself. mwIndex represents an index. mwSubArray represents the result of an index operation. The indexing routines themselves create mwSubArray objects when an indexing expression appears as the target of an assignment operation (on the left-hand side of an assignment operator). The library handles mwSubArray objects for you; you do not need to create them.


 Dimensions and Subscripts in MATLAB Array Storage