There is a special code in Matlab® to create and solve polynomials in a very easy way. The code is ‘polyval()’ code. In this article, we will explain the use of this code to obtain polynomes in Matlab® with a very basic example below.
How To Use ‘polyval()’ Code In Matlab®?
As you see above, we created a vector with the linspace() command, as shown by the red arrow. Then we created another vector that has the variables of 4, 5, 6, 1 respectively. In the polyval() command, we used these vectors respectively to solve the polynomial with variable x.
YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!
The polynomial is created with vector ‘a’. The variables represent the coefficients of the integer and other x^2, x^3, x^4 respectively by starting from left to right. For instance, in this example above, the vector ‘a’ represents the polynomial of ‘4x^3+5x^2+6x+1’. And this polynomial is calculated with all variables of vector ‘x’.
So we obtained a curve in Matlab® with polynomial ‘y’ and vector ‘x’ as shown by the orange arrow above.
Creating polynomials with polyval() command in Matlab® is very easy like above. Do not forget to leave your comments and questions about the ‘polyval()’ command in Matlab® 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