EE Comp MATLAB Activity 1

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

LYCEUM OF THE PHILIPPINES UNIVERSITY – LAGUNA

Km. 54, National Highway, Makiling, Calamba City, Laguna

COLLEGE OF ENGINEERING

ELEL40E – EE Computer Applications

MATLAB Laboratory Activity # 1


Polynomials, Linear Algebraic Equations, and
Partial Fraction Expansion

Pamplona, Mark Francis M.


BSEE 4-1

Ronel V. Vidal, PECE


instructor
A. POLYNOMIALS

1. Addition, Subtraction, Multiplication and Division of Polynomials


Pair 1
>> a=[1,2,3,-4];
>> b=[5,6,7,8];
Pair 2
>> c=[4,2,-1,3];
>> d=[10,-4,10,9];
>> A1=a+b %addition
A1 = 6 8 10 4 A1(x) = 6x3 + 8x2 + 10x + 4
>> f=c+d %addition
f =19 8 9 14 f(x) = 19x3 + 8x2 + 9x + 14
>> g=a-b %subtraction
g = -3 -5 -6 -1 g(x) = -3x3 - 5x2 - 6x - 1
>> h=c-d %subtraction
h = -1 4 -1 0 h(x) = -x3 + 4x2 - x
>> product=conv(a,b)
product =10 31 43 66 65 41 30 product = 10x6+31x5+43x4+66x3+65x2+41x+30
>> product=conv(c,d)
product =90 78 97171 76 63 49 product = 90x6+78x5+97x4+171x3+76x2+63x+49
>> [quotient,remainder]=deconv(a,b)
quotient = 0.4000 quotient = 0.4
remainder =0 -0.2000 -1.8000 2.6000 with remainder = -0.2x2 – 1.8x + 2.6
>> [quotient,remainder]=deconv(c,d)
quotient = 0.9000 quotient = 0.9
remainder =0 4.2000 -0.5000 0.7000 with remainder = 4.2x2 – 0.5x + 0.7

2. Scalar Multiplication of Polynomials

>> i=4*a
i = 8 12 4 20 i(x) = 8x3 + 12x2 + 4x + 20
>> j=5*b
j = 25 40 35 30 j(x) = 25x3 + 40x2 + 35x + 30
>> k=6*c
k = 54 36 24 42 k(x) = 54x3 + 36x2 + 24x + 42
>> l=7*d
l = 70 14 35 49 l(x) = 70x3 + 14x2 + 35x + 49
3. Polynomial Roots
The roots are:
>> m=roots(a)
m = -1.9186 m = -1.9186,
0.2093 + 1.1222i 0.2093 + 1.122j, and
0.2093 - 1.1222i 0.2093 - 1.122j
>> n=roots(b)
n =-1.2485 n = -1.2485,
-0.1757 + 0.9645i -0.1757 + 0.9645, and
-0.1757 - 0.9645i -0.1757 - 0.9645
>> o=roots(c)
o = -1.0000 o = -1,
0.1667 + 0.8660i 0.1667 + 0.8660j, and
0.1667 - 0.8660i 0.1667 - 0.8660j
>> p=roots(d)
p = 0.2791 + 0.9194i p = -0.7582 ,
0.2791 - 0.9194i 0.2791 + 0.9194j, and
-0.7582 0.2791 - 0.9194j

4. Polynomials Coefficient from Roots

>> poly(m)
ans = 1.0000 1.5000 0.5000 2.5000 m(x) = x3 + 1.5x2 + 0.5x + 2.5
>> poly(n)
ans =1.0000 1.6000 1.4000 1.2000 n(x) = x3 + 1.6x2 + 1.4x + 1.2
>> poly(o)
ans =1.0000 0.6667 0.4444 0.7778 o(x) = x3 + 0.67x2 + 0.44x + 0.78
>> poly(p)
ans = 1.0000 0.2000 0.5000 0.7000 p(x) = x3 + 0.2x2 + 0.5x + 0.7

5. Value of polynomial at specified values of x

>> r=[1:2:11];
>> polyval(a,r)
ans = 11 89 335 845 1715 3041
>> polyval(b,r)
ans = 26 234 866 2162 4362 7706
>> polyval(c,r)
ans = 26 316 1302 3416 7090 12756
>> polyval(d,r)
ans = 24 310 1332 3570 7504 13614
B. SOLUTION TO LINEAR ALGEBRAIC EQUATIONS

>> A=[4 1 -2 3;-3 3 -1 4;-1 2 5 1;5 4 3 -1]


A=
4w + x -2y + 3z = 16
4 1 -2 3 -3w + 3x -y + 4z = 20
-3 3 -1 4 -w + 2x + 5y + z = -4
-1 2 5 1 5w + 4x + 3y - 1z = -10
5 4 3 -1
>> det(A)
ans = -620 The answer gives the vector C,
>> B=[16;20;-4;-10]; which corresponds to the solution
>> C=A\B :
C = -0.1677 w = -0.1677,
0.1097 x = 0.1097,
-1.7484 y = -1.7484
4.3548 and z = 4.3548.

C. PARTIAL FRACTION EXPANSION WITH MATLAB

1.

>> num= [7 5 9 6]; 7x3 + 5x2 + 9x + 6


>> den= [2 4 2 3]; 2x3 + 4x2 + 2x + 3
>> [x,y,z]=residue(num,den)
x=

-4.8606
0.1803 - 0.4667i
0.1803 + 0.4667i

y=

-1.8907
-4.8606 0.18-0.47j 0.18+0.47j
-0.0546 + 0.8890i + + + 3.5
-0.0546 - 0.8890i x + 1.8907 x - (-.05+0.89j) x – (-.05-0.89)

z=

3.5000
2.

>> clear x4 + 5x3 + 16x2 + 26x + 22


>> num= [1 5 16 26 22];
x3 + 3x2 + 7x + 5
>> den= [1 3 7 5];
>> [x,y,z]=residue(num,den)
x=

0.5000 - 0.2500i
0.5000 + 0.2500i
2.0000
Partial – fraction expansion of num / den :
y=

-1.0000 + 2.0000i 2 0.5+0.25j + 0.5-0.25j +


+ 2
-1.0000 - 2.0000i x+1 x - (-1-2j) x – (-1+2j)
-1.0000

z=

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy