
Other Data Structures
34 34 34 34
and
sum(M,2)
is a 4-by-1-by-24 array containing 24 copies of the column vector
34
34
34
34
Finally,
S = sum(M,3)
adds the 24 matrices in the sequence. The result has size 4-by-4-by-1, so
it looks like a 4-by-4 array:
S=
204 204 204 204
204 204 204 204
204 204 204 204
204 204 204 204
Cell Arrays
Cell arrays in MATLAB are m ultidimensional arrays whose elements are
copies of other arrays. A cell array of empty matrices can be created with
the
cell function. But, more often, cell arrays are created by enclosing a
miscellaneous collection of things in curly braces,
{}. The curly braces are
also used w ith subscripts to access the contents of various cells. For example,
C = {A sum(A) prod(pr od(A))}
produces a 1-by-3 cell array. The three cells contain the m agic square, the
row vector of column sums, and the product o f all its elements. When
C
is displayed, you see
C=
[4x4 double] [1x4 double] [209227 89888000]
4-11
Komentarze do niniejszej Instrukcji