All ProgramsCAEMatLabMatLab Programming

How To Index An Element Of A Vector In MatLab®(Illustrated Explanation)

In general, matrices are used in mathematical calculations in Matlab®. Also, you can obtain vectors according to your purpose in Matlab®. For example, if you have a vector that includes your various numbers inside it, you could require taking a specific number to use it in another mathematical calculation in Matlab® which is called indexing. So in this text, we will show you how to index a number from a vector by showing a basic example below in Matlab®.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

How To Index A Number Of A Vector In Matlab®?

>> v = linspace(1,100,15)
z = 5*v(5)

v =

  Columns 1 through 9

    1.0000    8.0714   15.1429   22.2143   29.2857   36.3571   43.4286   50.5000   57.5714

  Columns 10 through 15

   64.6429   71.7143   78.7857   85.8571   92.9286  100.0000

z =



As you can see above, we created a vector by using the linspace command that includes 15 elements inside it. For example, we want to take the fifth element of this matrix then multiply it with 5 in Matlab®. As you can see above, it is very basic to do it. Only type v then write the which element that you want to use inside parentheses right after that.

It is very basic to do in Matlab® like that. But sometimes this method could very important in some mathematical calculations. Think about a situation that you obtained your experiment results as a vector. And you want to apply a specific value inside your experiment to a formula. You could simply index this value from your vector then obtain your mathematical calculation in Matlab®.


Do not forget to leave your comments and questions below about the use of the linspace() command in Matlab® below. 

If you want further coding examples about the linspace() command in Matlab®, inform us in the comments.

This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®

Your precious feedbacks are very important to us.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button