www.gusucode.com > robust 案例源码程序 matlab代码 > robust/MixedSensitivityH2LoopShapingExample.m

    %% Mixed-Sensitivity H2 Loop Shaping
% Shape the singular value plots of the sensitivity $S = (I+ GK)^{-1}$ and
% complementary sensitivity $T = GK(I+GK)^{-1}$.
%%
% To do so, find a stabilizing controller _K_ that minimizes the $H_2$ norm
% of:
%%
% 
% $${T_{{y_1}{u_1}}} \buildrel \Delta \over = \left[ {\begin{array}{*{20}{c}}
% {{W_1}S}\\
% {({W_2}/G)T}\\
% {{W_3}T}
% \end{array}} \right].$$
% 
%% 
% Assume the following plant and weights:
% 
% $$G(s) = \frac{{s - 1}}{{s - 2}},{\rm{ }}{W_1} = \frac{{0.1(s + 1000)}}{{100s + 1}},{\rm{ }}{W_2} = 0.1{\rm{, }}{W_3} = 0.$$
% 
%% 
% Using those values, construct the augmented plant P, as illustrated in
% the <docid:robust_ref.f10-71923> reference page. 

% Copyright 2015 The MathWorks, Inc.

s = zpk('s');
G = 10*(s-1)/(s+1)^2;
G.u = 'u2';
G.y = 'y';

W1 = 0.1*(s+1000)/(100*s+1); 
W1.u = 'y2';
W1.y = 'y11';

W2 = tf(0.1); 
W2.u = 'u2';
W2.y = 'y12';

S = sumblk('y2 = u1 - y');
 
P = connect(G,S,W1,W2,{'u1','u2'},{'y11','y12','y2'});
%%
% Use |h2syn| to generate the controller.  Note that this system has NMEAS
% = 1 and NCON = 1. 
[K,CL,GAM] = h2syn(P,1,1);
%%
% Examine the resulting loop shape.
L = G*K; 
S = inv(1+L); 
T = 1-S;
sigmaplot(L,'k-.',S,'r',T,'g')
legend('open-loop','sensitivity','closed-loop')