Casey Petersen EECS460; HW12 Part a....................................................................................................................................................... 1 Part b ...................................................................................................................................................... 1 Part c ....................................................................................................................................................... 2 close all clear all clc Part a s = tf('s'); num = exp(-2*s); den = (10*s+1)*(25*s+1); Ga = num/den; margin(Ga); hold on; Part b n = T = num den 2; 2; = (1-s*T/2/n)^n; = (1+10*s)*(1+25*s)*(1+s*T/2/n)^n; Casey Petersen EECS460; HW12 Gb = num/den; margin(Gb); Part c n = 1; num = (1-s*T/2/n)^n; den = (1+10*s)*(1+25*s)*(1+s*T/2/n)^n; Gc = num/den; margin(Gc); figure; nyquist(Ga); hold on; n = 1000; r = 1; th = linspace(0,2*pi,n); x = r*cos(th); y = r*sin(th); plot(x,y,'g');axis equal; Casey Petersen EECS460; HW12 Casey Petersen EECS460; HW12 close all clear all clc % Part a % syms Kp Ki s s = tf('s'); Ki=2; den = (s*(1+0.25*s)); Kp=1; i=1; num = ((Kp*s+Ki)*exp(-0.2*s)); Gp = tf(num/den); [Gm,Pm,Wgm,Wpm] = margin(Gp); for Kp = 0.9:0.0001:1 num = ((Kp*s+Ki)*exp(-0.2*s)); Gp = tf(num/den); % stepinfo(Gp) close all [Gm,Pm,Wgm,Wpm] = margin(Gp); gainMargin(:,i)=([Kp,Gm]); phaseMargin(:,i)=([Kp,Pm]); i=i+1; end % [val col]=max(gainMargin(2,:)); % gainMargin(:,col) [val col]=max(phaseMargin(2,:)); phaseMargin(:,col) % [val col]=min(phaseMargin(2,:)); % phaseMargin(:,col) % gainMargin(:,col) ans = 0.9597 77.1679 close all clear all clc Part a syms Kp Ki s Casey Petersen EECS460; HW12 s = tf('s'); Ki=2; den = (s*(1+0.25*s)); Kp=1; i=1; num = ((Kp*s+Ki)*exp(-0.2*s)); Gp = tf(num/den); [Gm,Pm,Wgm,Wpm] = margin(Gp); for Kp = 2.5552:0.000001:2.5554 num = ((Kp*s+Ki)*exp(-0.2*s)); Gp = tf(num/den); % stepinfo(Gp) close all [Gm,Pm,Wgm,Wpm] = margin(Gp); gainMargin(:,i)=([Kp,Gm]); phaseMargin(:,i)=([Kp,Pm]); i=i+1; end phaseMargin; Published with MATLAB® R2016a Casey Petersen EECS460; HW12 Problem 4 Step 1 ...................................................................................................................................................... 6 Step 2 ...................................................................................................................................................... 7 Step 3 ...................................................................................................................................................... 7 Step 4 ...................................................................................................................................................... 8 close all clear all clc Step 1 s = tf('s'); num = 100; den = (s^2+10*s+100); Gp = num/den; margin(Gp); Casey Petersen EECS460; HW12 Step 2 K=10^(18.65/20) Gp2 = K*Gp; figure(2) margin(Gp2); [Gm,Pm,Wgm,Wpm] = margin(Gp2); K = 8.5605 Step 3 Gc = 1/1.455*((1+0.0485*s)/(1+0.0229*s)); phi_m = 50-Pm a = (1+sind(phi_m))/(1-sind(phi_m)) T = 1/(30*sqrt(a)) aT = a*T Gc = 1/sqrt(a)*((1+a*T*s)/(1+T*s)) phi_m = Casey Petersen EECS460; HW12 29.4657 a = 2.9362 T = 0.0195 aT = 0.0571 Gc = 0.03333 s + 0.5836 -----------------0.01945 s + 1 Continuous-time transfer function. Step 4 figure(3) margin(Gc); figure(4) G=Gc*Gp2 margin(G); stepinfo(G) G = 28.54 s + 499.6 --------------------------------------0.01945 s^3 + 1.195 s^2 + 11.95 s + 100 Continuous-time transfer function. ans = RiseTime: SettlingTime: SettlingMin: SettlingMax: 0.1367 0.7836 4.6383 5.9785 Casey Petersen EECS460; HW12 Overshoot: 19.6718 Undershoot: 0 Peak: 5.9785 PeakTime: 0.3132 Casey Petersen EECS460; HW12 Published with MATLAB® R2016a