Adjusting Precisions Of Numbers And Symbolic Equations In MatLab®

Precision adjustments can be very important when you are making very accurate calculations. Matlab® provides various kinds of ways to adjust the precision of numbers and symbolic expressions. One of these ways is the use of the ‘vpa()’ command in Matlab®. 

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

Here, we explain how to use the ‘vpa()’ command in Matlab® to adjust the precision of variables and numbers. The code examples below are executed in the Matlab® command window. You can try it in your software also. 

How To Use ‘vpa()’ Command In MatLab®?

>> vpa(17/7,10)
 
ans =
 
2.428571429
 
>> 

As you see in the very basic example above, we wrote two elements inside the ‘vpa()’ command. The first element is the numerical expression which is ’17/7′ above. And the second element is the precision value that we want. 

The precision value is the number of digits that we want to see after the decimal comma. If you check the example above, the number of digits after the comma is 15. 

Precision Of Symbolic Equations And Expressions In MatLab®

>> syms a b
vpa(10*a/7*b,10)
 
ans =
 
1.428571429*a*b
 
>> 

As you see in the example above, we created two symbolic variables ‘a’ and ‘b’ with the ‘syms’ command. 

And we defined our numerical expression with these variables. You can see the result. 

Conclusion

As you see that the use of the ‘vpa()’ command in MatLab® is very simple to adjust precisions of numbers and numerical expressions. 

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

If you want further coding examples about the ‘vpa()’ 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.

Comments

Leave a Reply

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