|MATLAB Function Reference|
d = size(X)
returns the sizes of each dimension of array
X in a vector
ndims(X) elements. If
X is a scalar, which MATLAB regards as a 1-by-1 array,
size(X) returns the vector
[m,n] = size(X)
returns the size of matrix
X in separate variables
m = size(X,dim)
returns the size of the dimension of
X specified by scalar
[d1,d2,d3,...,dn] = size(X),
n > 1, returns the sizes of the dimensions of the array
X in the variables d1,d2,d3,...,dn, provided the number of output arguments
n does not equal
ndims(X), the following exceptions hold:
For a Java array, |
Example 1. The size of the second dimension of
rand(2,3,4) is 3.
Here the size is output as a single vector.
Here the size of each dimension is assigned to a separate variable.
Example 2. If X = ones(3,4,5), then
But when the number of output variables is less than ndims(X):
The "extra" dimensions are collapsed into a single product.
If n > ndims(X), the "extra" variables all represent singleton dimensions:
© 1994-2005 The MathWorks, Inc.