Practical 6: Polynomial Functions
Practical 6
Commands
Table of some MATLAB polynomial commands
roots([c1 c2 c3]) | finds the roots of a polynomial given its array of coefficients, [c1 c2 c3]. |
poly([r1 r2]) | constructs a coefficient array, given the roots, [r1 r2], of the desired polynomial. |
polyval(p,x) | finds the value of the polynomial with coefficient array p at any given number x. |
conv(p,q) | multiply two polynomials, and , with coefficient arrays, p and q |
[Q,R]=deconv(p,q) |
finds the quotient and remainder of polynomial division, p(x)/q(x) |
> Exercise: Multiplying Polynomials > Define two polynomials p(x) and q(x) as coefficient arrays p and q in MATLAB p=[ 1 2 3], q=[2 1] > use conv function to multiply them conv(p,q) > Now, by hand, convert the arrays p and q back to polynomials and multiply them. Compare your result with the one you received from MATLAB. Is the MATLAB result trustworthy? |
> Exercise: Finding Polynomial Roots > Find the roots of two polynomials, p(x) and q(x), with coefficient arrays p and q p = [3 -4 0 7 -9 3] q = [4 5 -6] |
> Exercise: Dividing Polynomials > Multiply p(x) and q(x) by using the conv function and corresponding coefficient arrays. > Use deconv function to find the remainder and quotient of p(x)/q(x)
|
> Exercise: Re-creating Polynomials from Given Roots > Find a polynomial with roots r1=5, r2=-5, r3=4, r4=-4. |