Using the C Math Library | ![]() ![]() |
Overview
An N-dimensional subscript contains N indices. The first index is the row index, the second is the column index, the third the page index, and so on. When you use the MATLAB C Math Library to perform N-dimensional indexing, you pass mlfIndexRef()
N index arrays as arguments that together represent the subscript. The first index array argument stores the row index, the second the column index, the third the page index, and so on. Each index array can store a scalar, vector, matrix, or the result from a call to the function mlfCreateColonIndex()
.
The size of the indices determines the size of the result. The size of the result is equal to the product of the sizes of the N indices. For example, assume matrix A
is set to:
1 4 7 2 5 8 3 6 9
If you index matrix A
with a 1-by-5 vector and a scalar, the result is a five-element vector: five elements in the first index times one element in the second index. If you index matrix A
with a three-element row index and a two-element column index, the result has six elements arranged in three rows and two columns.
There is no functional difference between two-dimensional indexing and N-dimensional indexing (where N > 2). See Extending Two-Dimensional Indexing to N Dimensions to learn how to work with arrays of dimension greater than two.
To use the code samples in your own code, see Assumptions for the Code Examples, which explains the conventions used in the examples.
![]() | N-Dimensional Indexing | Selecting a Single Element | ![]() |