s=tf('s');
rho=sqrt(2);
A=[-1 0 ; 1 -1];Bd = [0;1];Bu=[1;0];
Cz = [0 1/rho; 0 0 ]; Dzd = [0;0];Dzu = [0;1]
Cy = [0 0];Dyd = 1; Dyu = 0;
B=[Bd Bu];C=[Cz;Cy]; D = [Dzd Dzu;Dyd Dyu];
P = ss(A,B,C,D);

gamv = roots([1 2 0 0 -1/rho^2])
gamma = gamv(2)


NMEAS=1;NCON=1;
[K,CL,GAM,INFO] = hinfsyn(P,NMEAS,NCON,'TOLGAM',1e-6)
figure(1)
bode(K,{1e-2,1e5})
hold on
% z = rho^(-2)*gamma^(-2)
% k = -1/(1-sqrt(1+z));
% K1 = -(s+1)/(k*(s+1)+1);
% bode(K1)
figure(2)
sigma(CL,{1e-2,1e5})
