% Practice problems 6.2, 6.3, 6.12 % Jeff Pieper % March 2004 clear % Problem 6.2 w = [ 1 2 5 10 20 50 100 ] ; G = tf(1,[1 10]) ; [m,p]=bode(G,w) ; for k=1:length(w), mdb(k) = 20*log10(m(:,:,k)) ; ph(k) = p(:,:,k) ; end mlow = 20*log10(1/10) ; figure(1) clf subplot(2,1,1) semilogx(w,mdb,'x',[1 10],[mlow mlow],'-b',[10 100],[mlow mlow-20],'-b') xlabel('Frequency (r/s)') ylabel('magnitude (dB)') title('Exact versus asymptote frequency response of 1/s+10') axis([1 100 -50 -10]) subplot(2,1,2) semilogx(w,ph,'x',[1 10],[0 0],'-b',[10 10],[0 -90],'-b',[10 100],[-90 -90],'-b') xlabel('Frequency (r/s)') ylabel('phase (deg)') axis([1 100 -100 10])

% problem 6.3 clear Ga = tf(4000,[1 400 0]) ; Gb = tf(100,conv([0.1 1 0],[0.5 1])) ; Gc = tf(1,conv([1 1 0],[0.02 1])) ; Gd = tf(1,conv([1 2 1],[1 2 4])) ; Ge = tf([10 40],conv([1 1 0],[1 2 5])) ; Gf = tf([1000 100],conv([1 1 0],[1 8 64])) ; Gg = tf(conv([1 5],[1 3]),conv([1 1 0],[1 1 4])) ; Gh = tf([4 40 0],conv([1 100],[4 5 4])) ; Gi = tf([1 0],conv([1 1],conv([1 10],[1 2 2500]))) ; w= logspace(-2,4,200) ; for j=1:9, switch j case 1 G=Ga ; msg = 'part a' ; case 2 G=Gb ; msg = 'part b' ; case 3 G=Gc ; msg = 'part c' ; case 4 G=Gd ; msg = 'part d' ; case 5 G=Ge ; msg = 'part e' ; case 6 G=Gf ; msg = 'part f' ; case 7 G=Gg ; msg = 'part g' ; case 8 G=Gh ; msg = 'part h' ; case 9 G=Gi ; msg = 'part i' ; end [m,p]=bode(G,w) ; for k=1:length(w), mdb(k) = 20*log10(m(:,:,k)) ; ph(k) = p(:,:,k) ; end figure(1+j) clf subplot(2,1,1) semilogx(w,mdb) xlabel('Freq (r/s)') ylabel('mag (dB)') title(msg) subplot(2,1,2) semilogx(w,ph) xlabel('Freq (r/s)') ylabel('Phase (deg)') end % problem 6.12 clear pole=[0.01 0.1 1 10 100] ; w = logspace(-2,2,100) ; figure(11) clf hold on for j=1:5, G = tf(1,conv([1/pole(j) 1],[1 1 1])) ; [m,p] = bode(G,w) ; for k=1:length(w), mdb(k) = 20*log10(m(:,:,k)) ; ph(k) = p(:,:,k) ; end msg = ['pole = ',num2str(pole(j))] ; subplot(2,1,1) semilogx(w,mdb) hold on xlabel('Freq (r/s)') ylabel('mag (dB)') text(1,mdb(50),msg) subplot(2,1,2) semilogx(w,ph) hold on xlabel('Freq (r/s)') ylabel('Phase (deg)') text(1,ph(50),msg) end

E x a c t v e r s u s a s y m p t o t e f r e q u e n c y r e s p o n s e o f 1 / s + 1 0 - 1 0

- 2 0 ) B d (

e d

u - 3 0 t i n g a

m - 4 0

- 5 0 0 1 2 1 0 1 0 1 0 F r e q u e n c y ( r / s )

0

- 2 0 ) g e d

( - 4 0

e s a

h - 6 0 p

- 8 0

- 1 0 0 0 1 2 1 0 1 0 1 0 F r e q u e n c y ( r / s ) p a r t a 1 0 0

5 0 ) B d (

0 g a m

- 5 0

- 1 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

- 8 0

- 1 0 0 ) g

e - 1 2 0 d ( e s a - 1 4 0 h P

- 1 6 0

- 1 8 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

p a r t b 1 0 0

5 0

0 ) B d (

- 5 0 g a m - 1 0 0

- 1 5 0

- 2 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

- 5 0

- 1 0 0 ) g

e - 1 5 0 d ( e s a - 2 0 0 h P

- 2 5 0

- 3 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

p a r t c 5 0

0

- 5 0 ) B d (

- 1 0 0 g a m - 1 5 0

- 2 0 0

- 2 5 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

- 5 0

- 1 0 0 ) g

e - 1 5 0 d ( e s a - 2 0 0 h P

- 2 5 0

- 3 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s ) p a r t d 0

- 1 0 0 ) B d (

- 2 0 0 g a m

- 3 0 0

- 4 0 0 -2 -1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

0

- 1 0 0 ) g e d (

e - 2 0 0 s a h P - 3 0 0

- 4 0 0 -2 -1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

p a r t e 1 0 0

0 ) B d (

- 1 0 0 g a m

- 2 0 0

- 3 0 0 -2 -1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

- 5 0

- 1 0 0 ) g e - 1 5 0 d ( e s a - 2 0 0 h P

- 2 5 0

- 3 0 0 -2 -1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

p a r t f 5 0

0

) - 5 0 B d ( g a - 1 0 0 m

- 1 5 0

- 2 0 0 -2 -1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

0

- 5 0

) - 1 0 0 g e d (

e - 1 5 0 s a h

P - 2 0 0

- 2 5 0

- 3 0 0 -2 -1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s ) p a r t g 1 0 0

5 0

0 ) B d (

- 5 0 g a m - 1 0 0

- 1 5 0

- 2 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

- 5 0

- 1 0 0 ) g e d (

e - 1 5 0 s a h P - 2 0 0

- 2 5 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

p a r t h - 2 0

- 4 0 ) B d (

- 6 0 g a m

- 8 0

- 1 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

1 0 0

5 0 ) g e d (

e 0 s a h P - 5 0

- 1 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

p a r t i - 5 0

- 1 0 0 ) B d (

- 1 5 0 g a m

- 2 0 0

- 2 5 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

1 0 0

0 ) g e d (

e - 1 0 0 s a h P - 2 0 0

- 3 0 0 - 2 - 1 0 1 2 3 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s ) 5 0

0 p o l e = 1 0 0 p o l e = 0 . 1 p o l e = 0 . 0 1 ) - 5 0 B d ( g a - 1 0 0 m

- 1 5 0

- 2 0 0 - 2 - 1 0 1 2 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )

0

- 5 0 p o l e = 1 0 0 ) - 1 0 0 g e

d p o l e = 1 (

e - 1 5 0 s p o l e = 0 . 1 a p o l e = 0 . 0 1 h

P - 2 0 0

- 2 5 0

- 3 0 0 - 2 - 1 0 1 2 1 0 1 0 1 0 1 0 1 0 F r e q ( r / s )