MATLAB length

length() command or function gives the number of elements in a vector or length of largest matrix size, after reading this MATLAB length topic, you will know the theory and examples.


Syntax:

length(n)

  • n can be a vector or matrix.

Example: To find the number of elements in a vector.

Output:

ans =

4

Example: To find the number of elements present in each column the matrix.

Output:

n =

1   2   3
3   2   1
4   5   1
23  2   1


ans =

4

Leave a Comment

error: Content is protected !!