systemnames = 'P0 WT WS'; inputvar = '[ w1; w2; u ]'; outputvar = '[ WT; WS; w2-w1-P0 ]'; input_to_P0 = '[ u ]'; input_to_WT = '[ P0 ]'; input_to_WS = '[ w2-P0-w1 ]'; cleanupsysic = 'yes'; Ghat = sysic; gam_low = 1e-5; gam_high = 10.0; while gam_high - gam_low > 1e-4 gam = (gam_low + gam_high) / 2.; [K, clp, gopt] = hinfsyn(mdiag(1,1/gam,1)*Ghat, 1, 1, 'GMIN', 1., 'GMAX', 1, 'DISPLAY', 'off'); fprintf('gam = %f ... ', gam); if isempty(K) fprintf('infeasible\n'); gam_low = gam; else fprintf('feasible\n'); gam_high = gam; K_opt = K; gam_opt = gam; end end figure(7); for c=0.8:0.05:1.2 P = 1/((s-1)*(c*s + 1)); S_tilde = 1/(1 + P * K_opt); bodemag(S_tilde, 'r'); hold on; end S = 1/(1 + P0 * K_opt); bodemag(S, 'b', gam_opt/WS, 'g'); % now the problem has been solved title('sensitivity gain for perturbed plant'); hold off; figure(8); T = 1 - S; % gain plot of complementary sensitivity function bodemag(T, 'b', 1/WT, 'g'); legend('T', '1/WT'); title('complementary sensitivity gain');