This text shows how to obtain vectors in Matlab® and how to create vector variables in Matlab® codes. As its name implies, Matlab® generally works with the base of matrices. Also, vectors are matrices and you could do various matrice calculations with your created vector in Matlab®. Also, you could do mathematical calculations with Matlab® vectors and you could insert the Matlab® vector to mathematical calculations with other matrices, vectors, and individual variables. This is much easier in Matlab® coding compared with other software languages.
YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!
How Is The Creation Of Vectors In Matlab®?
v = [1 0 0] d = [1; 2; 3] z = 1:.5:3 p = pi*[-4:2:4]/4
There are a bunch of vector examples in the Matlab® script above, we will talk about their working principles below.
>> v = [1 0 0] d = [1; 2; 3] z = 1:.5:3 p = pi*[-4:2:4]/4 v = 1 0 0 d = 1 2 3 z = 1.0000 1.5000 2.0000 2.5000 3.0000 p = -3.1416 -1.5708 0 1.5708 3.1416 >>
As you can see the v vector is very basic and shows how to create a vector in Matlab® in principle. d vector shows how to create column vectors in Matlab®. You could understand that if you put ‘;’ between vector numbers, this vector will be a column vector like d. The meaning of z vector, ve create the z vector starts with 1, ends with 3, and increment of each element in z vector is 0.5. You could type the first value, increment value, and end value to create a vector by putting ‘:’ between these values.
In p vector, we did a bunch of mathematical calculations by using a vector-like z. As you can see we multiplied an increment vector with pi and divided it with 4.
Do not forget to leave your comments and questions below about the vector creation in Matlab® below.
If you want further coding examples about ‘the vector creation 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.