fprintf('executing ex1102_1: conservative design\n');
ex1102_1; % 
gam2 = gam_opt
K2 = K_opt;

fprintf('executing ex1116_1: less conservative design\n');
ex1116_1; % less conservative design
gam3 = gam_opt
K3 = K_opt;

Delta_tilde = [0, 1/sqrt(2); 0, -1/sqrt(2)]; % example of non-structured uncertainty
fprintf('***1st check for singular values of Delta_tilde:');
svd(Delta_tilde) % less than or equal to 1

fprintf('***2nd check for closed-loop stability of M2(Ghat(gamma2) and K2) and Delta_tilde:');
M2 = lft(mdiag(1,1/gam2,1)*Ghat, K2, 1, 1);
clp2 = lft(Delta_tilde, M2, 2, 2);
real(eig(clp2.a)) % closed-loop stability regardless the structure of uncertainty block

fprintf('***3rd check for closed-loop stability of M3(Ghat(gamma3) and K3) and Delta_tilde:');
M3 = lft(mdiag(1,1/gam3,1)*Ghat, K3, 1, 1);
clp3 = lft(Delta_tilde, M3, 2, 2);
real(eig(clp3.a)) % closed-loop instability by the non-structured uncertainty block

fprintf('***4th check for closed-loop H infinity norm of M3:');
norm(M3, 'inf') % larger than 1

fprintf('***5th check for closed-loop H infinity norm of M3 with scaling:');
W = mdiag(d_opt,1);
M3_d = W\M3*W;
norm(M3_d, 'inf') % less than 1
