next up previous contents
Next: LINSPACE Linearly Spaced Vector Up: Array Generation and Manipulations Previous: FLIPUD Reverse the Columns   Contents

Subsections

LENGTH Length of and Array

Usage

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.

Example

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 = 
  <uint32>  - size: [1 1]
            4


Samit K. Basu 2005-03-16