Practical 6: Polynomial Functions

Practical 6

Polynomials in MATLAB

In MATLAB, a polynomial is represented by an array of its coefficients of the powers. The MATLAB polynomial functions allow us to perform some useful commands such as addition, multiplication and finding the roots of polynomials.

Example:

p\left(x\right)=3x^{5}-4x^{4}+7x^{2}-9x+3=3x^{5}-4x^{4}+0x^{3}+7x^{2}-9x^{1}+3x^{0}

would be entered as

p = [3 -4 0 7 -9 3],

so that p(1)=3 is a coefficient for x^{5} (term with the highest power), p(2) =-4 is x^{4},.., p(6)=3 – for (the lowest power term).

> Exercise: Creating Coefficient Arrays

Write the polynomial p(x) corresponding to array of coefficients q

q = [4 5 -6]                            p\left(x\right) =

> Type in the coefficient array s corresponding to polynomial s(x)

s\left(x\right)=-4^{4}+3                             s=[ ]