
We will follow the following steps:Īs we can see in the output, we have obtained complex roots for the input polynomial x^2 + 1, as expected by us. In this example, we will take a polynomial of degree 2 and with complex roots.

Pass this column vector as an argument to the root functionĪs we can see in the output, roots of the input polynomial x^3 – 5x^2 +2x +8 are 4, 2, -1, which are the same as expected by us.

Let our input polynomial be x^3 –5x^2 + 2x+8.In this example, we will take a polynomial of degree 3. Passthiscolumn vector as an argument to the root functionĪs we can see in the output, roots of the input polynomial x^2 – x -6 are 3, -2, which are the same as expected by us.Initialize the input polynomial in the form a column vector.Let our input polynomial be x^2 – x – 6.

In this example, we will take a polynomial of degree 2. Let us now understand the code of roots functions in MATLAB using different examples: Example #1
