Programming |
Cell Arrays of Structures
Use cell arrays to store groups of structures with different field architectures:
cStr = cell(1,2); cStr{1}.label = '12/2/94 - 12/5/94'; cStr{1}.obs = [47 52 55 48; 17 22 35 11]; cStr{2}.xdata = [-0.03 0.41 1.98 2.12 17.11]; cStr{2}.ydata = [-3 5 18 0 9]; cStr{2}.zdata = [0.6 0.8 1 2.2 3.4];
Cell 1 of the cStr
array contains a structure with two fields, one a string and the other a vector. Cell 2 contains a structure with three vector fields.
When building cell arrays of structures, you must use content indexing. Similarly, you must use content indexing to obtain the contents of structures within cells. The syntax for content indexing is
For example, to access the label
field of the structure in cell 1, use cStr{1}.label
.
Converting Between Cell and Numeric Arrays | Function Summary |
© 1994-2005 The MathWorks, Inc.