% T84e.m format compact clc clear N = [1]; syms s; Ds = expand ((s+1)*(s+2)*(s+3)) % expand pole terms to poly expression % Ds = s^3+6*s^2+11*s+6 D = poly([-1 -2 -3]) % convert poles to polynomial vector G = tf (N, D) rlocus (G) % Select system gain disp ('stability condition: K < 60') K = input ('Enter K: '); % Bode plot figure % for new window bode (K*G) % checking specific values on Bode Plot w = input ('Enter w: ') Gjw = evalfr (K*G, j*w); Gmag = abs(Gjw), Garg = angle(Gjw) * 180/pi dB = 20 * log10(Gmag) % closed loop poles T = K*G / (1 + K*G) Tmr = minreal (T) closed_loop_poles = pole (Tmr) % Nyquist plot figure nyquist (K*G) % Compute system margins [gm,pm,wg,wp] = margin (K*G) gm_dB = 20 * log10(gm) % Nichols diagram figure nichols (K*G) % pause for the user and remove figures display ('Hit Enter to continue'); pause close all