We explained the creating vectors with the ‘linspace()’ command in Matlab®. There is another command that you can create vectors differently compared to linspace() called logspace(). In this article we will explain;
- The logic of logspace() command in Matlab®.
- How to use logspace() command in Matlab®.
What Is Logspace() Command In Matlab®?
>> a = logspace(1,3,6)
b=a*3
c=b+1
a =
1.0e+03 *
Columns 1 through 5
0.0100 0.0251 0.0631 0.1585 0.3981
Column 6
1.0000
b =
1.0e+03 *
Columns 1 through 5
0.0300 0.0754 0.1893 0.4755 1.1943
Column 6
3.0000
c =
1.0e+03 *
Columns 1 through 5
0.0310 0.0764 0.1903 0.4765 1.1953
Column 6
3.0010
To create vectors in Matlab® with the logspace() command, you just need to type three numbers inside the parentheses of logspace(). You can assign this command to a variable as shown above. And also you do mathematical calculations with the vectors created by the logspace() command in Matlab®.
YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!
The first number inside the parentheses means the first element of the vector will start with this exponent of 10. As you see from the above example, we typed the number of ’1’ inside logspace() command, the first number is the multiplication of 1.0r+03(1000 in a scientific expression) with 0.01 which equals 10. So 10 over 1 is 10.
The second that is typed inside the parentheses of logspace() means at which exponent of 10 the last number will be. We typed as ‘3’, which means the last number is 10 over 3. As you see from the above example results that the last number is 1.0e+03*1.0000 which equals 1000.
The last number that we typed, divides the last and first exponents into equal spacing in that number. So the number of elements inside the created vector with logspace() command in Matlab® will be that number. We entered it as ‘6’, and the exponents of 10 in each element are divided 6, between 1 and 3.
Conclusion
The use of logspace() command in Matlab® can be expressed like above. If you have any questions or comments about the logspace() command in Matlab®, do not forget to leave them below!
This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®
Your precious feedbacks are very important to us.
Leave a Reply