Biomedical Engineering Reference
In-Depth Information
A.1.6 Polynomials and Roots
MATLAB works with polynomials using a row vector and can calculate the roots of the
polynomial using a built-in function. A polynomial is written as a row vector of the poly-
nomial coefficients in descending order, starting with the highest order. Consider the
polynomial
4
3
2
x
12
x
þ
0
x
þ
25
x þ
116
¼
0
ð
A
:
12
Þ
which is entered in MATLAB as
>>
p
¼
[1
12
0
25
116]
returning
p
¼ 1
12
0
25
116
It is important to enter every term, even terms with a 0 coefficient as in Equation (A.12).To
find the roots of the polynomial, we use the built-in function “roots”. To find the roots of
Equation (A.12), we write
>>
r
¼
roots(p)
and MATLAB returns with two real roots and a pair of complex conjugate roots:
r
¼ 11.7473
2.7028
1.2251
þ
1.4672i
1.2251
1.4672i
The convention for MATLAB is that polynomials are row vectors and roots are column
vectors. One can work in the opposite direction and find the polynomial given as a
set of roots via the MATLAB “poly” command. Continuing from the last MATLAB cal-
culations to find the roots of a polynomial, use the “poly” command to restore the
polynomial
>>
pp
¼
poly(r)
which returns
pp
1.0000
12.0000
0.0000
25.0000
116.0000
Polynomial multiplication is carried out using the MATLAB function “conv”, which per-
forms the convolution of the two polynomials. Consider multiplying the following two
polynomials using MATLAB.
3
2
A
(
x Þ¼ x
þ
2
x
þ
3
x þ
4
ð
A
:
13
Þ
3
2
B
(
x Þ¼ x
þ
4
x
þ
9
x þ
16
ð
A
:
14
Þ
Search WWH ::




Custom Search