0% found this document useful (0 votes)
7 views8 pages

Poly

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views8 pages

Poly

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

MATLAB

POLYNOMIALS
LECTURE OVERVIEW

• Polynomial Multiplication and Division.


• Polynomial Roots.
• Polynomial Coefficients.
• Plotting Polynomials.
POLYNOMIAL MULTIPLICATION AND
DIVISION
• conv(a,b) computes the product of the two
polynomials described by the coefficient arrays a
and b. The result is the coefficient array of the
product polynomial.

• [q,r] = deconv(a,b) computes the result of dividing


a polynomial ‘a’, by a polynomial ‘b’. The quotient
polynomial is given by the coefficient array q, and
the remainder polynomial is given by the coefficient
array r.
EXAMPLES

>> a = [9,-5,3,7];
>> b = [6,-1,2];
>> product = conv(a,b)
product =
54 -39 41 29 -1 14
>>[quotient, remainder] = deconv(a,b)
quotient =
1.5 -0.5833
remainder =
0 0 -0.5833 8.1667
POLYNOMIAL ROOTS

• roots(a) computes the roots of a polynomial


specified by the coefficient array a. The result is a
column vector that contains the polynomial’s roots.
• For example,
>>r = roots([2, 14, 20])
r=
-2
-5
POLYNOMIAL COEFFICIENTS

• poly(r) computes the coefficients of the polynomial


whose roots are specified by the vector r. The result
is a row vector that contains the polynomial’s
coefficients arranged in descending order of
power.
• For example,
>> c = poly([-2, -7])
c=
1 7 10
PLOTTING POLYNOMIALS

• polyval(a,x) evaluates a polynomial at specified


values of its independent variable x, which can be
a matrix or a vector.
–The polynomial’s coefficients of descending powers
are stored in the array a.
–The result is the same size as x
EXAMPLE OF PLOTTING A
POLYNOMIAL
• To plot the polynomial
𝑓 (𝑥) = 9𝑥 3 – 5𝑥 2 + 3𝑥 + 7 for –2 ≤x ≤5,
you type

>>a = [9,-5,3,7];
>>x = [-2:0.01:5];
>>f = polyval(a,x);
>>plot(x,f),
xlabel(’x’),
ylabel(’f(x)’)

You might also like