ACT3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

ECE120L – INTRODUCTION TO MATLAB

LABORATORY ACTIVITY #3
Polynomials and Partial Fraction Expansion

Name: Consuegra, Carlo Date: 11/19/2018


Section: A23 Laboratory Instructor: M. I. Alipio

I. Learning Outcomes:
At the end of the laboratory activity, the students should be able to:
1. To describe polynomials in MATLAB
2. To implement polynomials addition, subtraction, scalar multiplication, multiplication, and division with
MATLAB
3. To determine the roots of polynomials
4. To implement partial – fraction expansion with MATLAB

II. Laboratory Activity:


1.
a. Problem: Polynomial

b. MATLAB Codes:
1.
>> f=[1, -8, 0, -9, -6];
>> g=[0, 1, 1, -3, 1];
>> a=f+g
>> b=f-g
>> product=conv(f,g)
>> quotient=deconv(f,g)

>> h=[3, -8, -37, 2, 4];


>> p=[0, 2, 3, -2, 5];
>> a=h+p
>> b=h-p
>> product=conv(h,p)
>> quotient=deconv(h,p)
2.
>> f=[1,-8,0,-9,-6];
>> g=[0,1,1,-3,1];
>> h=[3,-8,-37,2,4];
>> p=[0,2,3,-2,5];
>> f1=4*f;
>> g1=5*g;
>> h1=6*h;
>> p1=7*p;

3.
>> f=[1, -8, 0, -9, -6];
>> g=[0, 1, 1, -3, 1];
>> h=[3, -8, -37, 2, 4];
>> p=[0, 2, 3, -2, 5];
>> roots(f)
>> roots(g)
>> roots(h)
>> roots(p)
4.
>> poly1=poly(rf);
>> poly2=poly(rg);
>> poly3=poly(rh);
>> poly4=poly(rp);
5.
>>a=[1,3,5,-2];
>>polyval(f,a)
>>polyval(g,a)
>>polyval(h,a)
>>polyval(p,a)

c. Answer:
1.
a=

1 -7 1 -12 -5
b=

1 -9 -1 -6 -7
product =

Columns 1 through 8

0 1 -7 -11 16 -23 21 9
Column 9

-6

quotient =

1 -9

a=

3 -6 -34 0 9
b=

3 -10 -40 4 -1
product =

Columns 1 through 8

0 6 -7 -104 -76 48 -177 2

Column 9

20
quotient =

1.5000 -6.2500
2.
f1 =

4 -32 0 -36 -24


g1 =

0 5 5 -15 5
h1 =

18 -48 -222 12 24
p1 =

0 14 21 -14 35

3.
ans =

8.1467
0.1904 + 1.1661i
0.1904 - 1.1661i
-0.5276

ans =

-2.4142
1.0000
0.4142

ans =

5.0653
-2.4296
0.3450
-0.3140

ans =

-2.3681
0.4340 + 0.9313i
0.4340 - 0.9313i

4.
poly1 =

1.0000 -8.0000 0.0000 -9.0000 -6.0000


poly2 =

1.0000 1.0000 -3.0000 1.0000


poly3 =

1.0000 -2.6667 -12.3333 0.6667 1.3333


poly4 =

1.0000 1.5000 -1.0000 2.5000

5.
ans =

-22 -168 -426 92


ans =

0 28 136 3
ans =
-36 -296 -36 -36
ans =

8 80 320 5

2.
a. Problem: Partial – Fraction Expansion with MATLAB

b. MATLAB Codes:

>> num=[0 10 70];


>> den=[1 9 18];
>> [r,p,k]=residue(num,den)

>> num=[0 1 2 4 1 0 3];


>> den=[1 7 3 2 1 0 3];
>> [r,p,k]=residue(num,den)

>> num=[0 1 2 5 1 1];


>> den=[1 3 2 4 5 2];
>> [r,p,k]=residue(num,den)

>> num=[1 4 1 5];


>> den=conv([1 8],[1 8 3]);
>> den1=conv(den,[1 5 7]);
>> [r,p,k]=residue(num,den1)

c. Answer:

r=

-3.3333
13.3333

p=

-6
-3

k=

[]

r=

0.8322
0.0798
0.0423 - 0.2635i
0.0423 + 0.2635i
0.0017 - 0.1173i
0.0017 + 0.1173i

p=

-6.5869
-0.9470
-0.2834 + 0.8642i
-0.2834 - 0.8642i
0.5504 + 0.5278i
0.5504 - 0.5278i

k=

[]

r=

1.0486
0.3140 - 0.2522i
0.3140 + 0.2522i
-0.3383 - 0.7823i
-0.3383 + 0.7823i

p=

-2.5797
0.4432 + 1.1784i
0.4432 - 1.1784i
-0.6534 + 0.2494i
-0.6534 - 0.2494i

k=

[]

r=

-2.7849
2.7684
-0.0008 + 0.1278i
-0.0008 - 0.1278i
0.0182

p=

-8.0000
-7.6056
-2.5000 + 0.8660i
-2.5000 - 0.8660i
-0.3944

k=

[]

You might also like