
Sixth Section
6. Cells and Structures
Structures are collections of different kinds of data organized by named
fields. Cell arrays are a special class of Matlab arrays whose elements
consist of cells that themselves contain Matlab arrays. Both structures and
cell arrays provide a hierarchical storage mechanism for dissimilar kinds of
data. They differ from each other primarily in the way they organize data.
You access data in structures using named fields, while in cell arrays data is
accessed through matrix indexing operations [2].
6.1 Cells
A cell array is a Matlab array for which the elements are cells, containers
that can hold other Matlab arrays. For example, one cell of a cell array might
contain a real matrix, another an array of text strings, and another a vector
of complex values [2]. Moreover, you can build cell arrays of any valid size or
shape, including multidimensional structure arrays. Figure 14 gives an
illustration on how a 2-by-2 cell array might look.
cell (1,1)
+ iInf
NaN
53
5
cell (1,2)
?'Yours'
'PanayiotisisnameMy'
cell (2,1)
[ ]
cell (2,2)
cell (1,1)
[ ]
cell (1,2)
'Hello World'
cell (2,1)
[1 2 5 6]
cell (2,2)
+ iInf
NaN
53
5
Figure 14: A 2-by-2 cell array
Kommentare zu diesen Handbüchern