
%Plant (2.26)
G=nd2sys([-2,1],[50 15 1],3);  % original plant 
g=G;

% H-infinity design (weighted sensitivity) (SiS, 23 AUG 96)

% Performance weight Wp
% Require  wb=z/2=0.5/2=0.25, slope 1 and peak less than  1.5
M=1.5; wb=0.25; Wp = nd2sys([1/M wb], [1 1.e-6]); 
Wu=1; %may consider increasing to 2

systemnames = 'G Wp Wu';
inputvar = '[ r(1); u(1)]';
outputvar = '[Wp; Wu; r-G]';
input_to_G = '[u]';
input_to_Wp = '[r-G]';
input_to_Wu = '[u]';
sysoutname = 'P';
 cleanupsysic = 'yes';
sysic;

nmeas=1; nu=1; gmn=0.5; gmx=20; tol=0.001;
[khinf,ghinf,gopt] = hinfsyn(P,nmeas,nu,gmn,gmx,tol);

c=khinf; 

% Analysis
gc = mmult(g,c);
s = minv(madd(1,gc));
t = msub(1,s);
u=1;
y1 = trsp(t,u,50,0.1);
%input signal
gs = mmult(c,s); u1=trsp(gs,u,50,0.1);
% Simulate
subplot(111),vplot(y1,'-',u1,'--',1,':')
axis([0 50 -0.5 2.5]);
text(40,1.15,'yt');text(40,0.2,'ut');
xlabel('Time');%ylabel('y');



