# Indexing The Number Of Elements Of A Vector In MatLab(Illustrated Expression)

Indexing means that you can assign the numerical feature to a variable in Matlab. Indexing tools and commands in Matlab is also very superior compared with other programming languages. Because of this reason, Matlab is a very superior mathematical calculation programming language. Also you can index the number of elements of a vector in Matla to a variable. You can do this kind of thing with ‘length()’ command in Matlab. In this article, we will show the use of length() command in Matlab witha very basic example below.

### How To Use ‘length()’ Command In MatLab?

For example we have an vector called as ‘a’, and the number of elements of this vector ‘a’ is ‘6’ as shown by green arrows above. We created a variable called ‘b’ with lenght(a), which has a value of ‘6’ as shown bt red arrows above. So you see that, the number of elements of ‘a’ is the value of ‘b’.

As you can see from the ‘c’ and ‘d’ variables, we can do various mathematical calculations with that length() function as shown by orange and blue arrows above.

This lenght() code can be very useful in such calculations. For example you have a vector that each element represents the grade of a student in your class. When you add a grade to that vectori the number of students of this class also increases. If you need a mathematical calculation with student number, you can use this lenght() command that will use the updated student number inside the vector.

The use of lenght() command in Matlab is very easy and useful like above. Do not forget to leave your comments and questions about ‘length()’ command in Matlab below!