length - Length of vector

Syntax

n = length(X)

Description

The statement length(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

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS