Creating Polynomials In MatLab(Illustrated Expression)
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?
Use of polyval() command in Matlab.
As you see above, we created a vector with linspace() command, as shown by red arrow. Then we created another vector that has the variables of 4, 5, 6, 1 recpectively. In polyval() command, we used these vectors respectively to solve teh polynom with variable x.
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 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 ‘polyval()’ command in Matlab below!