% reduced-order controller design with improper weighting function clear all; close all; s = tf('s'); Ap = [0, 1, 0; 0, -10, 64.1; 0, -43.6, 0]; Bp = [0; 0; 5.97]; Cp = [1, 0, 0]; P0 = ss(Ap, Bp, Cp, 0); figure(1); bode(P0); WS = 100/(s^2 + s + 1); WT = ((s^2 + 2*1*31.4*s + 31.4^2)*314^2*0.8)/((s^2 + 2*1*314*s + 314^2)*31.4^2) * (s/31.4 + 1)/(s/314 + 1); WTimp = ((s^2 + 2*1*31.4*s + 31.4^2)*314^2*0.8)/(314^2 * 31.4^2) * (s/31.4 + 1); % controller design with proper weight WT systemnames = 'P0 WT WS'; inputvar = '[ w; u ]'; outputvar = '[ WS; WT; w+P0 ]'; input_to_P0 = '[ u ]'; input_to_WT = '[ P0 ]'; input_to_WS = '[ w+P0 ]'; cleanupsysic = 'yes'; G = sysic; [K, clp, gopt] = hinfsyn(G, 1, 1, 'DISPLAY', 'on'); % controller design with improper weight WTimp P0tf = tf(P0); a2 = P0tf.den{1}(2); a1 = P0tf.den{1}(3); a0 = P0tf.den{1}(4); bp = P0tf.num{1}(4); b3 = WTimp.num{1}(1); b2 = WTimp.num{1}(2); b1 = WTimp.num{1}(3); b0 = WTimp.num{1}(4); WTimpP0 = ss([0, 1, 0; 0, 0, 1; -a0, -a1, -a2], [0; 0; 1], [bp*(b0-b3*a0), bp*(b1-b3*a1), bp*(b2-b3*a2); bp, 0, 0], [bp*b3; 0]); systemnames = 'WTimpP0 WS'; inputvar = '[ w; u ]'; outputvar = '[ WS; WTimpP0(1); w+WTimpP0(2) ]'; input_to_WTimpP0 = '[ u ]'; input_to_WS = '[ w+WTimpP0(2) ]'; cleanupsysic = 'yes'; Gimp = sysic; [Kimp, clpimp, goptimp] = hinfsyn(Gimp, 1, 1, 'DISPLAY', 'on'); figure(2); bode(K, 'b--', Kimp, 'r'); legend('with WT', 'with WTimp'); grid on; axis([0.01, 100, 80, 330]); % phase h = get(2); axis(h.Children(4),[0.01, 100, 10, 70]); % gain S = 1/(1 - P0*K); T = 1 - S; Simp = 1/(1 - P0*Kimp); Timp = 1 - Simp; figure(3); bodemag(S, 'r', gopt/WS, 'r--', T, 'b', gopt/WT, 'b--', ... Simp, 'g', goptimp/WS, 'g--', Timp, 'm', goptimp/WTimp, 'm--'); legend('S', 'gamma/WS', 'T', 'gamma/WT', ... 'Simp', 'gamma/WSimp', 'T', 'gammaimp/WTimp'); axis([0.01, 100, -60, 30]); grid on; % step response figure(4); t = 0:0.01:1'; step(T, 'b--', Timp, 'r', t)