LENGTH Length of an Array

Section: Inspection Functions


Returns the length of an array x. The syntax for its use is
   y = length(x)

and is defined as the maximum length of x along any of its dimensions, i.e., max(size(x)). If you want to determine the number of elements in x, use the numel function instead.


For a 4 x 4 x 3 matrix, the length is 4, not 48, as you might expect.
--> x = rand(4,4,3);
--> length(x)

ans =