Sie sind auf Seite 1von 19

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

Solution to Homework Assignment 1


1. (Review) Consider the system with transfer function G(s) = 30 Y (s) = 3 . R(s) s + 10s2 + 31s + 30 (1)

(a) For input r(t) = (t), t 0, nd the corresponding output y(t) using partial fraction expansions and inverse Laplace transforms. Then use Matlab to obtain the solution and plot the solution on the interval t = [0, 2]. (b) Repeat for r(t) = u(t), t 0. (c) Repeat for r(t) = t, t 0. Note: In this course you must always label your plot properly using Matlab commands title, xlabel, and ylabel. Solution: We consider three dierent inputs, which I will label as follows: r1 (t) = (t) r2 (t) = u(t) r3 (t) = t Then R1 (s) = 1 R2 (s) = 1/s R3 (s) = 1/s2

(2)

Lets call the corresponding outputs y1 (t), y2 (t), y3 (t). 30 . (3) s3 + 10s2 + 31s + 30 The denominator factors as (s + 2)(s + 3)(s + 5), which I could obtain using the Matlab command roots([1 10 31 30]) or by trial and error, noting that if the roots are integers they must be factors of 30. Y1 (s) = G(s)R1 (s) = Taking the partial fraction expansion we have Y1 (s) = which implies that 30 = a(s2 + 8s + 15) + b(s2 + 7s + 10) + c(s2 + 5s + 6) or 0 = (a + b + c)s2 0 = (8a + 7b + 5c)s 30 = 15a + 10b + 6c. This is equivalent to the linear equation

30 a b c = + + s3 + 10s2 + 31s + 30 s+2 s+3 s+5

(4)

(5)

(6) (7) (8)

1 1 1 0 a 7 5 b , 0 = 8 15 10 6 30 c

(9)

ECE382/ME482 Spring 2008 which has solution

Homework 1 Solution

September 22, 2008

or Then

1 1 1 a 7 5 b = 8 15 10 6 c a b c =

0 0 , 30 .

(10)

10 15 5

(11)

Y1 (s) = = so inverse transforming,

30 s3 + 10s2 + 31s + 30 15 5 10 + + s+2 s+3 s+5

(12)

y1 (t) = 10e2t 15e3t + 5e5t , Repeating the process for y2 (t) we nd Y2 (s) = G(s)R2 (s) = s3 + 10s2 30 + 31s + 30

t 0.

(13)

1 . s

(14)

The denominator factors as (s + 2)(s + 3)(s + 5)s. Taking the partial fraction expansion we have Y2 (s) = = which implies that 30 = as(s2 + 8s + 15) + bs(s2 + 7s + 10) + cs(s2 + 5s + 6) + d(s3 + 10s2 + 31s + 30) (16) or 0 = (a + b + c + d)s3 0 = (8a + 7b + 5c + 10d)s 30 = 30d. This is equivalent to the linear equation

2

30 + 31s + 30 b c a + + + s+2 s+3 s+5 s3 + 10s2

1 s d s

(15)

(17) (18) (19) (20)

0 = (15a + 10b + 6c + 31d)s

0 0 0 30

a 1 1 1 1 b 8 7 5 10 15 10 6 31 c d 0 0 0 30

(21)

ECE382/ME482 Spring 2008 which has solution


Homework 1 Solution

September 22, 2008

a b c d

or Then

1 1 1 1 8 7 5 10 15 10 6 31 0 0 0 30 =

0 0 0 30

(22)

a b c d

5 5 1 1

(23)

Y2 (s) = = so inverse transforming,

30 s4 + 10s3 + 31s2 + 30s 5 1 1 5 + + + s+2 s+3 s+5 s

(24) (25)

y2 (t) = 5e2t + 5e3t e5t + 1, Finally, repeating the process for y3 (t) we nd Y3 (s) = G(s)R3 (s) = s3 + 10s2

t 0.

(26)

30 + 31s + 30

1 . s2

(27)

The denominator factors as (s + 2)(s + 3)(s + 5)s2 . To obtain the partial fraction expansion we use the residue command as follows: >> [r,p,k] = residue(30,[1 10 31 30 0 0]) r = 0.2000 -1.6667 2.5000 -1.0333 1.0000

p = -5.0000 -3.0000 -2.0000 0 0

k =

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

[]

Thus Y3 (s) = s5 + 10s4 1/5 5/3 5/2 1 3/100 1 30 = + + + + 2 3 + 30s2 + 31s s+2 s+3 s+5 s s (28)

so inverse transforming we have, to four decimal places, y3 (t) = 5 2t 5 3t 1 5t e + e + e 1.0333 + t, 2 3 5 t 0. (29)

To obtain the plots we use a Matlab script such as the following. (I did the calculations two ways to show the agreement between the results.) %%% %%% Problem 1, Homework 1 %%% t = [0:.01:10]; %%% First the solutions we calculated analytically. for index = 1:1001, y1a(index) = 10*exp(-2*t(index)) - 15*exp(-3*t(index)) + 5*exp(-5*t(index)); y2a(index) = -5*exp(-2*t(index)) + 5*exp(-3*t(index)) - exp(-5*t(index)) + 1; y3a(index) = 5/2*exp(-2*t(index)) + -5/3*exp(-3*t(index)) + ... 1/5* exp(-5*t(index)) - 1.0333 + t(index); end %%% Next the solutions calculated using Matlab. gnum = 30; gden = [1 10 31 30]; sys = tf(gnum,gden); y1b = impulse(sys,t); u2 = ones(size(t)); y2b = lsim(sys,u2,t); %%% or equivalently y2b = step(sys,t); g3num = 30; g3den = [1 10 31 30 0]; sys3 = tf(g3num,g3den); y3b = step(sys3,t); figure(1) subplot(2,1,1) plot(t,y1a,b,t,y1b,r) title(Problem 1 Comparison of Analytical and Numerical Solutions) xlabel(t)

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

ylabel(Impulse Response y_1) legend(Analytical,Numerical) grid subplot(2,1,2) plot(t,y1a-y1b) xlabel(t) ylabel(Error (analytical - numerical)) grid print -depsc figure1 figure(2) subplot(2,1,1) plot(t,y2a,b,t,y2b,r) title(Problem 1 Comparison of Analytical and Numerical Solutions) xlabel(t) ylabel(Step Response y_2) legend(Analytical,Numerical) grid subplot(2,1,2) plot(t,y2a-y2b) xlabel(t) ylabel(Error (analytical - numerical)) grid print -depsc figure2 figure(3) subplot(2,1,1) plot(t,y3a,b,t,y3b,r) title(Problem 1 Comparison of Analytical and Numerical Solutions) xlabel(t) ylabel(Ramp Response y_3) legend(Analytical,Numerical) grid subplot(2,1,2) plot(t,y3a-y3b) xlabel(t) ylabel(Error (analytical - numerical)) grid print -depsc figure3

and we obtain the results 2. (Review) Consider an input r(t) = t, t 0 applied to a system with transfer function G(s). The corresponding output is y(t) = e3t 2e2t + et 2. Find G(s).

Solution: We know that G(s) = Y (s)/R(s). Thus we just need to take Laplace transforms

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

Problem 1 Comparison of Analytical and Numerical Solutions 0.8 Impulse Response y1 Analytical Numerical 0.6

0.4

0.2

5 t

10

5 Error (analytical numerical) 0 5 10 15 20

x 10

15

5 t

10

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

Problem 1 Comparison of Analytical and Numerical Solutions 1 0.8 0.6 0.4 0.2 0 Analytical Numerical

Step Response y2

5 t

10

5 Error (analytical numerical)

x 10

15

10

5 t

10

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

Problem 1 Comparison of Analytical and Numerical Solutions 10 Ramp Response y3 8 6 4 2 0 Analytical Numerical

5 t

10

3.3333 Error (analytical numerical)

x 10

3.3333

3.3333

3.3333

3.3333

5 t

10

ECE382/ME482 Spring 2008 of r(t) and y(t).

Homework 1 Solution

September 22, 2008

R(s) = L[r(t)] =

1 s2

(30) (31) (32)

Y (s) = L[y(t)] = = so G(s) =

2 1 2 1 + s+3 s+2 s+1 s 2(s3 + 6s2 + 10s + 6) s(s + 1)(s + 2)(s + 3) 2s(s3 + 6s2 + 10s + 6 . (s + 1)(s + 2)(s + 3)

(33)

Notice that this is an improper transfer function (order of numerator greater than order of denominator). I used Matlab as shown below to help with some of the algebra. >> [1 3 2 0]-2*[1 4 3 0]+[1 5 6 0] - 2*conv([1 3 2],[1 3]) ans = -2 -12 -20 -12

3. (Review) Consider the initial value problem (IVP) consisting of the dierential equation y + 6y + 3y = u, where u(t) is the unit step function, and the initial conditions y(0) = 0 (a) Find the solution ya (t) analytically. (b) Find the solution yb (t) using Matlab. (c) Using the subplot command, plot in the upper half of the space ya (t) and yb (t) on the same graph; and plot in the lower half the dierence ya (t) yb (t). (This error should be very small.) (d) Remember to properly label the graphs. Solution: and y(0) = 0. (35) (34)

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

10

(a) Taking the Laplace transform of 34, we obtain Ya (s) = G(s)U (s) = s(s2 1 , + 6s + 3) (36)

then factor the denominator so we can do a partial fraction expansion. Using the formula for the roots of a second order equation we nd that (37) s2 + 6s + 3 = (s + 3 + 6)(s + 3 6). The partial fraction expansion is then Ya (s) = s(s2 1 C A B + = + + 6s + 3) s s+3+ 6 s+3 6 (38)

where A = 1/3, B = 3/8, and C = 0.3708 to four decimal places according to the Matlab calculations shown below. (I could work it out by hand but it would be tedious and not very informative.) >> a = 1; >> b = [1 6 3 0]; >> [r,p,k]=residue(a,b) r = 0.0375 -0.3708 0.3333

p = -5.4495 -0.5505 0

k = [] Thus, again rounding to four decimal places, we obtain Ya (s) = 0.3708 0.375 1/3 + + . s s + 0.5505 s + 5.4495 (39)

Taking the inverse Laplace transform to get ya (t) yields 1 0.3708e0.5505t + 0.375e5.4495t , t 0. (40) 3 Parts (b), (c), and (d) are very similar to what I provided for Problem 1, so I will not include them here. ya (t) =

ECE382/ME482 Spring 2008 4. (Section 2.3) Suppose that

Homework 1 Solution

September 22, 2008

11

y(r, ) = mr 2 + mr cos m2 sin .

(41)

Find the rst order linear approximation to y(r, ) near the operating point (r, ) = (r0 , 0 ). Note that the function y is declared to be a function of two variables: r, and . Therefore m and are constants. Solution: Taylors formula for the linear approximation near the point (r0 , 0 ) is y y(r, ) y(r0 , 0 ) + = r (r r0 ) + y ( 0 ) (42)

(r0 ,0 )

(r0 ,0 )

The partial derivatives evaluated at the point (r0 , 0 ) are y r and y = 2mr0 + m cos 0 ,
(r0 ,0 )

(43)

(r0 ,0 )

= mr0 sin 0 m2 cos 0 .

(44)

Thus
2 y(r, ) mr0 + mr0 cos 0 m2 sin 0 + = (2mr0 + m cos 0 )(r r0 ) +

(mr0 sin 0 m2 cos 0 )( 0 ).

(45)

I could simplify this equation further by expanding all of the products and rearranging to obtain y(r, ) = a(r, )r + b(r, ) + c where the constants r0 and 0 would be parameters (as opposed to variables) of the functions a, b, and the constant c. I would ordinarily simplify, but in this case I found that the result provided little additional insight.

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

12

5. (Section 2.6) Consider the transfer function blocks that we reduced in lecture on 8/28. (If you have the 11th edition, the diagram is in Figure 2.26 on p. 75.) Delete block H2 . Add a new negative feedback loop H4 from the output of G2 to the leftmost summer. Insert in the forward path from the input to this summer a block G5 . You are given that G1 (s) = 1 s+1 s G2 (s) = 2 s +2 1 G3 (s) = 2 s G4 (s) = 1 G5 (s) = 4 H1 (s) = 50 s2 + 2 H3 (s) = 3 s + 14 4s + 2 . H4 (s) = 2 s + 2s + 1 (a) Find the transfer function from R(s) to Y (s). Solution: We can reduce the two inner feedback loops as shown below.
H4

(46) (47) (48) (49) (50) (51) (52) (53)

R(s)

Y(s)

G5

G1

G2

G3
+

G4

H1

H3

R(s)

G1G2

G3G4 1 G3G4H1

Y(s)

G5

1 + G1G2H4

H3

Figure 1: Problem 5: Block diagram and rst simplication step. It will be easier to do the nal reduction step if we simplify the two large blocks now. Let B1 (s) = G1 (s)G2 (s) 1 + G1 (s)G2 (s)H4 (s) (54)

ECE382/ME482 Spring 2008

Homework 1 Solution
s (s+1)(s2 +2) s(4s+2) (s+1)(s2 +2)(s+1)2

September 22, 2008

13

= = =

1+

(55) (56) (57)

s(s + 1)3 (s2 + 2) (s + 1)(s2 + 2) ((s + 1)3 (s2 + 2) + s(4s + 2)) s(s + 1)2 . s5 + 3s4 + 5s3 + 11s2 + 8s + 2

>> conv([1 3 3 1],[1 0 2]) + [0 0 0 5 2 0] ans = 1 Similarly let B2 (s) = = = G3 (s)G4 (s) 1 G3 (s)G4 (s)H1 (s)
1 s2

11

(58) (59) (60)

1 50 s2 1 . s2 50

Then the forward path of the last feedback loop has transfer function B1 (s)B2 (s) = s(s + 1)2 (s2 50)(s5 + 3s4 + 4s3 + 11s2 + 8s + 2) (61)

and feedback path H3 (s). Finally, Y (s) R(s) = = G5 (s)B1 (s)B2 (s) 1 + B1 (s)B2 (s)H3 (s) (62)

4s(s + 1)2 (s3 + 14) (63) . (s1 0 + 3s9 45s8 125s7 200s6 1177s5 2344s4 3485s3 7668s2 559s 1400)

I used Matlab command conv to multiply polynomials >> anum = conv(4*[1 2 1 0],[1 0 0 14]) anum = 4 8 4 56 112 56 0

>> test = conv(conv([1 5 3 11 8 2],[1 0 -50]),[1 0 0 14]) test = Columns 1 through 5

ECE382/ME482 Spring 2008 1

Homework 1 Solution 5 -47

September 22, 2008 -225 -72

14

Columns 6 through 10 -1206 Column 11 -1400 -3746 -2088 -7672 -5600

>> aden = conv(conv([1 5 3 11 8 2],[1 0 -50]),[1 0 0 14]) + [ 0 0 0 0 0 conv([1 2 1 aden = Columns 1 through 5 1 Columns 6 through 10 -1205 Column 11 -1400 >> roots(anum) ans = 0 1.2051 + 2.0872i 1.2051 - 2.0872i -2.4101 -1.0000 -1.0000 >> roots(aden) ans = 7.0709 -7.0716 -4.7831 1.2049 + 2.0866i 1.2049 - 2.0866i -3744 -2085 -7668 -5598 5 -47 -225 -72

ECE382/ME482 Spring 2008 -2.4107 0.2760 0.2760 -0.3837 -0.3837

Homework 1 Solution

September 22, 2008

15

+ + -

1.4580i 1.4580i 0.2066i 0.2066i

We nd that the transfer function is s(s + 1)2 Y (s) = R(s) (s + 2.5443)(s2 0.3789s + 3.9583)(s2 + 0.8346s + 0.1986) (b) Find the closed loop poles and zeros . (Use Matlab if necessary.) Solution: See above. (c) Let H1 (s) = H3 (s) = H4 (s) = 0 and nd the transfer function from R(s) to Y (s). Solution: The open loop transfer function is just the product of the Gi , namely 4s 4 = . s2 (s + 1)(s2 + 2) s(s + 1)(s2 + 2) (d) Find the poles and zeros of this open loop transfer function. Solution: Clearly the poles are 0, 1, 2, 2. (65) (64)

ECE382/ME482 Spring 2008 6. (Section 2.7)

Homework 1 Solution

September 22, 2008

16

Create a signal ow graph for the closed loop system of the previous problem. Use Masons formula to compute the transfer function from R(s) to Y (s). (If it does not match that you found in the previous problem, you need to nd and correct your mistakes.)
H4 G5 R G1 L2 G2 L3 L1 H1 H3 1 G3 G4 Y

Figure 2: Problem 6: Signal Flow Graph. Solution: A drawing of the signal ow graph corresponding to the block diagram is given in Figure 2. There is a single path from R(s) to Y (s), namely P1 = G1 G2 G3 G4 G5 . There are three loops: L1 = G1 G2 G3 G4 H3 (66) (67) (68)

L3 = G3 G4 H1 .

L2 = G1 G2 H4

(Any other possible loop would encounter some node twice.) Every loop touches the path so 1 = 1. L2 and L3 are non-touching loops so the graph determinant is = 1 L1 L2 L3 + L2 L3 = 1 + G1 G2 G3 G4 H3 + G1 G2 H4 G3 G4 H1 . Then the closed loop transfer function is G1 G2 G3 G4 G5 Y (s) = R(s) 1 + G1 G2 G3 G4 H3 + G1 G2 H4 G3 G4 H1 G1 G2 H4 G3 G4 H1 (70) (69)

Heres the transcript of a Maple session that shows that the resulting transfer function is identical. > # ECE382 HW1 > # > restart: > #
>

# Problem 4 y := m*r^2+m*l*r*cos(theta) - m*l^2*sin(theta); y := m r 2 + m l r cos() m l2 sin()

>

ECE382/ME482 Spring 2008


>

Homework 1 Solution

September 22, 2008

17

dydr := diff(y,r); dydr := 2 m r + m l cos() dydth := diff(y,theta); dydth := m l r sin() m l2 cos() yapp := subs({r=r0,theta= theta0},y) + subs({theta = theta0,r=r0},dydr)*(r-r0) + subs({theta = theta0,r=r0},dydth)*(theta-theta0);

>

> > >

+ (m l r0 sin(0) m l2 cos(0)) ( 0) > collect(yapp,{r,theta});

yapp := m r0 2 + m l r0 cos(0) m l2 sin(0) + (2 m r0 + m l cos(0)) (r r0 )

(m l r0 sin(0) m l2 cos(0)) + (2 m r0 + m l cos(0)) r + m r0 2 + m l r0 cos(0) m l2 sin(0) (2 m r0 + m l cos(0)) r0 (m l r0 sin(0) m l2 cos(0)) 0


>

#Problem 5 G1 := 1/(s+1); G1 := 1 s+1 s s2 + 2 1 s2

>

>

G2 := s/(s^2+2); G2 :=

>

G3 := 1/s^2; G3 :=

>

G4 := 1; G5 := 4;

G4 := 1
>

G5 := 4
>

H1 := 50; H1 := 50 H3 := (s^2+2)/(s^3+14); H3 := s2 + 2 s3 + 14 4s + 2 (s + 1)2

>

>

H4 := (4*s+2)/(s+1)^2; H4 :=

>

G1*G2/(1+G1*G2*H4);

ECE382/ME482 Spring 2008

Homework 1 Solution s

September 22, 2008

18

>

s (4 s + 2) ) (s + 1)3 (s2 + 2) B1 := simplify(G1*G2/(1+G1*G2*H4)); (s + 1) (s2 + 2) (1 + (s + 1)2 s s5 + 5 s3 + 3 s4 + 11 s2 + 8 s + 2 G3*G4/(1-G3*G4*H1); 1 50 s2 (1 2 ) s B2 := simplify(G3*G4/(1-G3*G4*H1)); 1 B2 := 2 s 50 G5*B1*B2/(1+B1*B2*H3); B1 := 4 (s + 1)2 s ((s5 + 5 s3 + 3 s4 + 11 s2 + 8 s + 2) (s2 50)

>

>

>

>

(s + 1)2 s (s2 + 2) )) (s5 + 5 s3 + 3 s4 + 11 s2 + 8 s + 2) (s2 50) (s3 + 14) B3 := simplify(G5*B1*B2/(1+B1*B2*H3)); (1 +

B3 := 4 s (s + 1)2 (s3 + 14)/(s10 125 s7 45 s8 1177 s5 200 s6 3485 s3 + 3 s9 2344 s4 7668 s2 5598 s 1400) > B3d := denom(B3);

B3d := s10 125 s7 45 s8 1177 s5 200 s6 3485 s3 + 3 s9 2344 s4 7668 s2 5598 s 1400
>

#Problem 6 P := G1*G2*G3*G4*G5; P := 4 (s + 1) s (s2 + 2) 1 (s + 1) s (s3 + 14) s (4 s + 2) (s + 1)3 (s2 + 2)

>

>

L1 := -G1*G2*G3*G4*H3; L1 :=

>

L2 := -G1*G2*H4; L2 :=

>

L3 := G3*G4*H1; L3 :=

50 s2 > Grdet := 1 - L1 - L2 - L3 + L2*L3; 1 s (4 s + 2) 50 50 (4 s + 2) Grdet := 1 + + 2 3 + 14) 3 (s2 + 2) (s + 1) s (s (s + 1) s (s + 1)3 s (s2 + 2) > sfg := simplify(P/Grdet);

ECE382/ME482 Spring 2008

Homework 1 Solution

September 22, 2008

19

sfg := 4 s (s + 1)2 (s3 + 14)/(s10 125 s7 45 s8 1177 s5 200 s6 3485 s3 + 3 s9 2344 s4 7668 s2 5598 s 1400) > simplify(B3-sfg); 0