Using the C Math Library | ![]() ![]() |
Indexing Nested Cell Arrays
To index nested cells, concatenate subscripts in the indexing string. The first set of subscripts accesses the top layer of cells, and subsequent sets of braces access successively deeper layers of cells.
For example, array A
illustrates nested cell arrays. A
is a 1-by-2 cell array itself and it contains a 2-by-2 cell array nested in cell {1,2}
.
Indexing the First Level
To access the 2-by-2 cell array in cell (1,2)
:
mlfIndexRef(A, "{?,?}", mlfScalar(1), mlfScalar(2))
In MATLAB A{1,2}
performs the same operation.
Indexing the Second Level
To access the scalar value in position {2,2}
of the cell array in cell {1,2}
:
mlfIndexRef(A, "{?,?}{?,?}", mlfScalar(1), mlfScalar(2), mlfScalar(2), mlfScalar(2))
A{1,2}{1,1}
in MATLAB performs the same operation.
![]() | Referencing a Subset of the Contents of a Cell | Assigning Values to a Cell Array | ![]() |