length
Length of the longest dimension.
Syntax
Section titled “Syntax”n = length(X)Description
Section titled “Description”Returns the largest dimension size of X. For a vector, this is the number of elements. For a matrix, it’s max(size(X)). For an empty array, returns 0.
For most array-shape questions, numel (total element count) or size (per-dimension) is more appropriate; length is most useful for vectors.
Examples
Section titled “Examples”length([10 20 30 40]) % 4length(zeros(3,5)) % 5length([]) % 0