Use Of Linspace Command In MatLab®(Illustrated Expression)

In Matlab® coding, sometimes there can be a requirement to create a vector that has specific start and end values. And these start and end values of this vector must be partitioned by a kind of integer. To do it, you could use the linspace command in Matlab®. You could create a vector that starts from a number, ends at another number and this gap is divided with an integer equally. You could see the use of linspace in Matlab® in this content.

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

Use Of Linspace Command In Matlab®

``````>> v = linspace(1,3,5)
d = 3*linspace(1,3,5)

v =

1.0000    1.5000    2.0000    2.5000    3.0000

d =

3.0000    4.5000    6.0000    7.5000    9.0000

>> ``````

We created two vectors in Matlab® called v and d by using the linspace command. The meaning of these linspace vectors in Matlab® is like that;

``````>> v = linspace(1,3,5)
d = 3*linspace(1,3,5)

v =

1.0000    1.5000    2.0000    2.5000    3.0000

d =

3.0000    4.5000    6.0000    7.5000    9.0000

>> ``````

As you can see the v vector that was created is a very straight use of the linspace command. It is very basic to use the linspace command that you need to only type numbers by putting commas between them in parentheses after typing linspace. v vector starts with integer 1 and ends with integer 3 then this vector includes 5 elements. So start and end values are divided according to the element number that you entered into the linspace command.

Conclusion

As you can see, you could do mathematical calculations with a linspace vector-like in d vector. The same linspace vector is multiplied with integer 3 in the d vector.

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

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