In this section we will see Matlab commands related to polynomials. Respectively:
Introducing a Polynomial to Matlab
$ latex P (s) = a s ^ 4 + b s ^ 3 + c s ^ 2 + d s + e
We will use the coefficients of the polynomial to introduce a polynomial of
If I define a line vector named ‘coefficient’, in Matlab this:
>> coefficient = [a b c d e]
I need to enter the form.
Thus, we will be able to easily perform operations such as finding the root of polynomials and multiplying them by using Matlab’s ready commands on the polynomial, where I enter the coefficients as line vectors.
$ latex P (s) = s ^ 4 +2 s ^ 3 + s ^ 2 + 3 s + 6
a polynomial of the form:
>> coefficient1 = [1 2 1 3 6]
We can enter it from the Matlab command screen.
Finding Roots of Polynomial in Matlab:
We will use the ‘roots’ command to find the roots of the polynomial.
We can find the roots of the Polynomial in Matlab, where we previously assigned the coefficients to a line vector.
Matlab roots command
roots (coefficients) or cocci = roots (coefficients)
$ latex P (s) = 1 s ^ (2) + 2 s +1
Finding the roots of the polynomial with Matlab.
>> coefficients = [1 2 1];
>> roots (coefficients)
$ latex s ^ 4 – 6 s ^ 3 + 11 s ^ 2 – 6 s
Finding the roots of the polynomial in Matlab:
>> coefficients = [1-6 11 -6 0];
>> rootz= roots (coefficients)
As seen in this example, if desired, the roots of the polynomial can be assigned to a variable. Here it is assigned to the variable named ‘rootz’. The values of the polynomial are 0, 3, 2 and 1.