S =1×2 struct array with fields:X
map
captionFor nonscalar structures, the syntax for accessing a particular field is
structName(indices).fieldName. Redisplay the clown image, specifying the index
for the clown struct ( 1 ):image(S(1).X)
colormap(S(1).map)Add indices to select and redisplay the upper left corner of the field contents:upperLeft = S(1).X(1:50,1:80);
image(upperLeft)NoteYou can index into part of a field only when you refer to a single element of a
structure array. MATLAB does not support statements such as S(1:2).X(1:50,1:80),
which attempt to index into a field for multiple elements of the structure.See Also
Related Examples
- “Access Data in Nested Structures” on page 11-14
- “Access Elements of a Nonscalar Struct Array” on page 11-16
- “Generate Field Names from Variables” on page 11-13
11 Structures