# 《自动控制原理》MATLAB实验指导书 Exp1 4

• 10 浏览

#### ching

2020/09/25 发布于 教育 分类

1. MATLAB 1 MATLAB MATLAB 2 3 MATLAB Matlab MATLAB , ( ) MATLAB MATLAB MATLAB M 1 MATLAB MATLAB MATLAB (Command Window) MATLAB > MATLAB 2 1 * / \ ^ 2 abs,sin,cos,tan,asin,acos,atan,sqrt,exp,imag,real,sign,log,log10,conj 1
2. 3 MATLAB x 4 12 x 3 0 x 2 25x 116 p=[1 -12 0 25 116] roots 0 0 poly r=roots(p) r= 11.7473 2.7028 -1.2251 + 1.4672i -1.2251 - 1.4672i p=poly(r) p= -12 -0 25 116 conv a=[1 2 3] ; b=[1 2] conv c=conv(a,b)=1 4 7 6 conv(conv(a,b),c) deconv [q,r]=deconv(c,b) q=1 2 3 r=0 0 0 polyder polyder(a)=2 2 polyval(p,n) n polyval(a,2)=11 p=polyfit(x,y,n) x y p 2 n
3. interp1 interp2 interp3 method Help polyfun xs ys x y method 4 nearest linear spline cubic spline 4 plot x1,y1,option1,x2,y2,option2, x1,y1 x,y option1 1 plot plot(y), plot(x,y), x plot(x,y s), y 1 y x y s Matlab x=linspace(0,2*pi,100); % 100 y=sin(x); % x y plot(x,y); [0 2 ] plot plot(x, sin(x), x, cos(x)) grid on grid off hold on 3
4. hold off axis [xmin xmax ymin ymax] axis( equal ) x text(x,y, y ) (x,y) gtext( ) title( ) xlabel( ) x ylabel( ) y \ legend( 1 subplot , 2 , , n ) mnk m: n: k: semilogx x 10 y semilogy y 10 x 3 MATLAB 1 G ( s) bm s m bm 1s m 1 ... b1s b0 an s n an 1s n 1 ... a1s a0 MATLAB 4
5. num = [bm bm-1 den = [an 0] an-1 0] sys = tf(num,den) G (s) k tf sys ( s z1 )( s z2 )...( s zm ) ( s p1 )( s p2 )...( s pn ) MATLAB z p z = [ z1 z2 p = [ p1 k m] p2 n] k =[ k ] sys = zpk(z,p,k) zpk sys x = ax + bu y = cx + du MATLAB a b sys = ss(a,b,c,d) ss c d sys 2 MATLAB ss2tf ss2zp tf2ss ss2tf tf2zp zp2tf tf2ss zp2ss zp2tf tf2zp zp2ss ss2zp 3 MATLAB parallel 5
6. [ n d ] = parallel n1 d1 n1 d1 n2 n2 d2 d2 g1 s 3 g1 (s) g2 2s 4 s 2s 3 g2 (s) s 4 s 2 n1 = [ 3 ] d1 = [ 1 4 ] n2 = [ 2 4 ] d2 = [ 1 2 3] [ n d ] = parallel n1 d1 n2 d2 0 5 18 25 1 6 11 12 n= d= g (s) 5s 2 18s 25 s 3 6s 2 11s 12 series [ n d ] = series n1 d1 n2 d2 feedback [ n d ] = feedback n1 d1 n2 d2 [ n d ] = feedback n1 d1 n2 d2 sign sign g1 (s) sign = -1 s 1 s 2s 3 2 g 2 ( s) 1 s 10 n1 = [ 1 1 ] d1 = [ 1 2 3 ] n2 = 1 6
7. d2 = [ 1 10 ] [ n d ] = feedback n1 d1 n2 d2 n= 0 1 11 1 12 10 d= g (s) 1 ( ) , ( ) 3. G ( s) s2 24 31 s 2 11s 10 12s 2 24s 31 ( ) ( ) , ( ) ( ) ( ) ( ) 2s 2 8s 6 ; s 3 8s 2 16s 6 4. X Y AX BU, A CX DU. 1 1 0 2 0 4 , B 6 2 10 1 2 0 0 , C 1 MATLAB 0 1 0 D 0. MATLAB parallel 3 1. MATLAB 2. 3 7 MATLAB
9. 3 simulink Math 4 Gain simulink Source Step untitled 5 simulink Sinks Scope untitled 6 Math Sum 7 8 Scope G (s) Z2 Z1 R2 R1 2 R1 100K , R2 200K SIMULINK 1-3 G( s) Z2 Z1 SIMULINK R2 R1 2 0.2s 1 R2 C1 1 R1 100K , R2 200K , C1 SIMULINK G( s) Z2 Z1 1 R1C1 s 1 0.1s SIMULINK 9 R1 100K , C1 1uf 1uf
10. 1-4 SIMULINK 1-5 G( s) Z2 Z1 R1C1 s SIMULINK s R1 100 K , C1 C2 10uf C1 SIMULINK 1-6 Z2 Z1 G(s) R1 R2 SIMULINK R2 ( R1C1 s 1) R1 100K , C1 10uf (0.1s 1) C2 C1 0.01uf SIMULINK G( s) Z2 Z1 R2 1 R1 C1 s (1 1 ) s 10 R1 R2 100K , C1 10uf 0.01uf
11. 1-7 + SIMULINK SIMULINK 1-8 + SIMULINK SIMULINK G1 ( s) 1 G1 ( s) G1 ( s) 1 G1 ( s ) s 1 1 s G1 ( s) s 2 1 0.5s 1 G2 ( s) G1 ( s) s 2 G1 ( s ) 1 1 G2 ( s ) s s 1 G2 (s) 1 1 2s SIMULINK 1 2 SIMULINK MATLAB SIMULINK 11
12. 1 step( ) impulse( ) 2 n 3 MATLAB MATLAB s num n num 1 MATLAB den m 1 step(num,den) t step(num,den,t) t [y x]=step(num,den) t=0:0.1:10 y x num,den C ( s) R( s) s 2 MATLAB num=[0 den=[1 0 4 25]; 25]; step(num,den) 12 25 4s 25
13. grid xlabel( ),ylabel( c(t) ) title( Unit-step Respinse of G(s)=25/(s^2+4s+25) ) text(3.4,- text(3.4,1.4, x=3.4,y=-0.06 x=3.4,y=1.4 t 0-10s num=[0 den=[1 0 25]; 4 25]; t=0:0.1:10; step(num,den,t) impulse (num,den) t impulse (num,den,t) t [y,x]=impulse(num,den) t=0:0.1:10 y [y,x,t]=impulse(num,den,t) x t C ( s) R(s) G (s) MATLAB 13 s 2 1 0.2s 1
14. num=[0 den=[1 0 1]; 0.2 1]; impulse(num,den) grid t -impulse Response of G(s)=1/(s G (s) sG(s) R(s)=1 C ( s) R( s) C (s) G( s) G(s) s 2 1 0.2s 1 sG(s) MATLAB num den 2-4 num=[0 den=[1 1 0]; 0.2 1]; step(num,den) grid -step Response of 3 MATLAB 14 s 2 s 1 0.2s 1 s
15. 1/s 1/s2 G(s) s C ( s) R(s) s G(s) 1 s 1 2 R(s)=1/s2 C ( s) s 1 s 1 2 1 s2 (s 1 s 1) s 2 1 s MATLAB num=[0 0 0 1]; den=[1 1 1 0]; step(num,den) -Ramp Response Cuve for System G(s)=1 n C ( s) R( s) n 2.0 2 n s2 2 n 1(rad / s) s 2 n 5 =0,0.25,0.5,1.0 MATLAB 5 15 hold
16. num=[0 0 1]; den1=[1 0 1]; den2=[1 0.5 1]; den3=[1 1 1]; den4=[1 2 1]; den5=[1 4 t=0:0.1:10; 1]; step(num,den1,t) grid text(4,1.7 ; hold step(num,den2,t) text (3.3,1.5 25 step(num,den3,t) text (3.5,1.2 step(num,den4,t) text (3.3,0.9 1.0 step(num,den5,t) text (3.3,0.6 2 -Response Curves for G(s n 0.25 1,2,3 n n num1=[0 0 1]; den1=[1 t=0:0.1:10; grid; 0.5 1]; step(num1,den1,t); hold on text(3.1,1.4 wn num2=[0 0 4]; den2=[1 1 16 4]; MATLAB
17. step(num2,den2,t); hold on text(1.7,1.4 wn=2 num3=[0 0 9]; den3=[1 1.5 9]; step(num3,den3,t); hold on text(0.5,1.4 wn=3 n 3 1 roots() MATLAB roots() s 4 10s 3 35s 2 50s 24 MATLAB >> roots([1,10,35,50,24]) ans = -4.0000 -3.0000 -2.0000 -1.0000 2 routh [r, info]=routh(den) den routh info routh routh 17 r
18. den=[1,10,35,50,24]; [r,info]=routh(den) r= 1 35 24 10 50 0 30 24 0 42 0 0 24 0 0 info= [] routh routh 1 MATLAB step( ) impulse( ) G(s) s 2 3s 7 4 s 3 6 s 2 4s 1 s4 2 G ( s) n n s2 2 2(rad / s ) n s 2 n 0,0.25,0.5,1.0 =0.25 =0.25 p , t r , t p , t s , ess , , , n 2s 4 G ( s) 2.0 n s 3 3s 2 5s 10 0 K ( s 2)( s 4)( s 2 6s 25) K 18
19. 1 MATLAB MATLAB 2. 3 K 4 1. MATLAB impulse( ) 2. 3 n 4 19 MATLAB step( )
20. 1. MATLAB 2. MATLAB 3. 4. s K MATLAB G (s) KG0 ( s) K b1 s m b2 s m 1 s n a1 s n 1 1 KG0 ( s) bm s bm bn 1s an 1 0 K K K MATLAB rlocus(num,den) rlocus(num,den,k) rlocus(p,z) r=rlocus(num,den) [r,k]=rlocus(num,den) G( s ) MATLAB 20 K s 3 ( s 1) 4s 2 2s 9
21. num=[1 den=[1 1]; 4 2 9]; rlocus (num,den) grid Real Axis Imaginary Axis Root Locus 3-1 3-2 MATLAB num=[1 den=[1 1]; 4 2 9]; k=1:0.5:10; rlocus (num,den,k) 2 K MATLAB rlocfind rlocfind K K r [k,r]=rlocfind(num,den) rlocus K num,den rlocfind r G( s) K 21 s 2 5s 6 s 3 8s 2 3s 25 1
22. 2 K 3 MATLAB G=tf([1,5,6],[1,8,3,25]); rlocus (G); [k,r]=rlocfind(G) G_c=feedback(G,1); step(G_c) 3-2 rlocfind 0.0264 K K (0.0264, ) K a b K=1 3-2 3 sgrid( ) n n MATLAB n sgrid( , n sgrid( ) ) n n G(s) 3-3 =0.707 1 s( s 1)( s 2) 3-3(a) G=tf(1,[conv([1,1],[1,2]),0]); zet=[0.1:0.2:1];wn=[1:10]; sgrid(zet,wn);hold on;rlocus(G) [k,r]=rlocfind(G) 22 rlocfind K
23. Select a point in the graphics window selected_point = -0.3791 + 0.3602i k= 0.6233 r= -2.2279 -0.3861 + 0.3616i -0.3861 - 0.3616i 3-3(b) K=0.6233 n 0.707 MATLAB r(2.3) G_c=feedback(G,1); step(G_c) dd0=poly(r(2:3,:)); wn=sqrt(dd0(3));zet=dd0(2)/(2*wn);[zet,wn] ans = 0.7299 0.5290 a b 3-3 4 rltool MATLAB 23
24. rltool rltool rltool(G) 3-4 G (s) s 0.125 s ( s 5)( s 20)( s 50) 2 den=[conv([1,5],conv([1,20],[1,50])),0,0]; num=[1,0.125]; G=tf(num,den); rltool(G) rltool 3-4 a Analysis Response to Step Command 3-4 b a b 3-4 GC ( s ) 181307.29 ( s 38.31)( s 10.26) ( s 61.3 j 0.84)( s 61.3 j 0.84) rltool 24
25. G(s) G (s) ( ) s(s 2 K 2 s 2)( s 2 6 s 13) K ( s 12) ( s 1)( s 12s 100)( s 10) 2 ( . ( . )( . ) . ) K 2. rltool 1 MATLAB 2. 3. K 4 5 1. rlocus() 2. MATLAB rlocfind(),sgrid() rltool 3. K 4 25