MATLAB校正系统程序
clear; G1=tf(20,[1,0.4,0]) %系统的开环传递函数 G=feedback(G1,1,-1) %原系统的闭环传递函数 figure(1) step(G) %原系统的单位阶跃响应 figure(2) rlocus(G1) %原系统的根轨迹 figure(3) margin(G1) %原系统的bode图 [Gm0,Pm0,Wg0,Wc0]=margin(G1) deta=5 %补偿角 Phim=45-Pm0+deta %校正装置最大超前角 a=sin(Phim*pi/180) alpha=(1+a)/(1-a) Wm=Wc0*alpha^(1/4) T=1/(Wm*sqrt(alpha)); alpha_T=alpha*T Gc=tf([alpha_T,1],[T,1]) %校正装置 Ga=G1*Gc %校正后的传递函数 G11=feedback(G1,1); %原系统闭环传递函数 Gaa=feedback(Ga,1); %校正后系统闭环传递函数 figure(4) rlocus(Ga)%校正后系统的根轨迹 legend( Ga ) figure(5) margin(Ga) %校正后系统的频域特性 [Gm,Pm,Wcm,Wpm]=margin(Ga) figure(6) step(G11, -.k ,Gaa)%原系统与校正后系统的时域特性的比较 legend( G1 , Ga ) figure(7) bode(G1, -.k ,Gc, : ,Ga)%原系统与校正后系统的频域特性的比较 legend( G1 , Gc , Ga ) G1 = 20 ----------- s^2 + 0.4 s Continuous-time transfer function. G = 20 ---------------- s^2 + 0.4 s + 20 Continuous-time transfer function. Gm0 = Inf Pm0 = 5.1214 Wg0 = Inf Wc0 = 4.4631 deta = 5 Phim = 44.8786 a = 0.7056 alpha = 5.7936 Wm = 6.9243 alpha_T = 0.3476 Gc = 0.3476 s + 1 ------------ 0.06 s + 1 Continuous-time transfer function. Ga = 6.952 s + 20 ---------------------------- 0.06 s^3 + 1.024 s^2 + 0.4 s Continuous-time transfer function. Gm = Inf Pm = 48.1787 Wcm = Inf Wpm = 6.9371 校正前 校正后