| MATLAB Function Reference | Search  Help Desk |
| length | Examples See Also |
Syntax
n=length(X)
Description
The statementlength(X) is equivalent to max(size(X)) for nonempty arrays and 0 for empty arrays.
n = length(X)
returns the size of the longest dimension of X. If X is a vector, this is the same as its length.
Examples
x = ones(1,8);
n = length(x)
n =
8
x = rand(2,10,3);
n = length(x)
n =
10
See Also
ndims, size