sizeArray size
s = size(A)A is an array.s of A.[s1,s2,...,sn] = size(A)s1, s2, ..., sn are the lengths of the 1st, 2nd, ..., n-th dimensions of A.ndims, i.e., n > ndims(A), the output sd is equal to 1 for d equal to ndims(A) + 1, ..., n.ndims, i.e., n < ndims(A), the last output sn is equal to the total number of elements in the remaining dimensions, i.e., size(A, n) * size(A, n + 1) * ... * size(A, ndims(A)).sd = size(A, d)d should be a real positive integer.sd, which is the length of the d-th dimension of A. d exceeds ndims(A), then sd is 1.size().% Random vector
r = rand(1,2,3,4);
disp('Size vector')
vec = size(r)
disp('Num of outputs == ndims(r).')
[s1,s2,s3,s4] = size(r)
disp('Num of outputs > ndims(r). The extra output s5 is 1.')
[s1,s2,s3,s4,s5] = size(r)
disp('Num of outputs < ndims(r). s3 is equal to size(r,3) * size(r,4).')
[s1,s2,s3] = size(r)
Size vector
vec =
1.0000 2.0000 3.0000 4.0000
Num of outputs == ndims(r).
s1 =
1.0000
s2 =
2.0000
s3 =
3.0000
s4 =
4.0000
Num of outputs > ndims(r). The extra output s5 is 1.
s1 =
1.0000
s2 =
2.0000
s3 =
3.0000
s4 =
4.0000
s5 =
1.0000
Num of outputs < ndims(r). s3 is equal to size(r,3) * size(r,4).
s1 =
1.0000
s2 =
2.0000
s3 =
12.000