Acl = A  + B2*K_opt;
Ccl = C1 + D12*K_opt;

% /////////////////////////////////////////////////////////////////////////
% 極配置仕様の確認：Acl = A + B2*K の固有値
% /////////////////////////////////////////////////////////////////////////
% ---------------------------------------------------
% 円領域の描画
theta = 0:0.01:2*pi;
x_circle = r*cos(theta) + c;
y_circle  = r*sin(theta);
figure(1);
plot(x_circle,y_circle,'linewidth',1.5)
hold on
% ---------------------------------------------------
% A + B2*K の固有値の描画
eigen = eig(Acl)
figure(1);
plot(real(eigen),imag(eigen),'x','linewidth',1.5,'markersize',10)
hold off
grid
axis('square')
xlim([-15 5])
ylim([-10 10])
set(gca,'fontsize',20,'fontname','arial')
xlabel('Re[\lambda]','fontsize',22,'fontname','arial')
ylabel('Im[\lambda]','fontsize',22,'fontname','arial')

% /////////////////////////////////////////////////////////////////////////
% H-infinity 制御仕様の確認
% /////////////////////////////////////////////////////////////////////////
% ---------------------------------------------------
% Gzw(jw) の特異値の計算
w = logspace(-2,2,500);
sys = ss(Acl,B1,Ccl,D11);
sv = sigma(sys,w);
% ---------------------------------------------------
% 特異値の描画
figure(2);
semilogx(w,sv,'b',[1e-2 1e2],gamma_opt*[1 1],'r--','linewidth',2)
grid
set(gca,'fontsize',20,'fontname','arial')
xlabel('frequency [rad/s]','fontsize',22,'fontname','arial')
ylabel('magnitude','fontsize',22,'fontname','arial')
set(gca,'xtick',[1e-2 1e-1 1e0 1e1 1e2])
legend('max\sigma[{G}_{zw}(j\omega)]','\gamma',3)

% ---------------------------------------------------
sys1 = ss(Acl,B1,-[Cp 0],1);    %%% sys1: w --> e
sys2 = ss(Acl,B1,-[Cp 0],0);    %%% sys2: w --> theta1
sv1 = sigma(sys1,w);            %%% sys1 の特異値の計算
sv2 = sigma(sys2,w);            %%% sys2 の特異値の計算
figure(3)
semilogx(w,20*log10(sv1),'b',w,20*log10(sv2),'r','linewidth',2)
hold on

sys3 = tf(gamma_opt*[1 0],bs);          %%% sys3: gamma/Ws(s)
sys4 = tf(gamma_opt*1,[bt2 bt1 bt0]);   %%% sys4: gamma/Wt(s)
sv3 = sigma(sys3,w);                    %%% sys3 の特異値の計算
sv4 = sigma(sys4,w);                    %%% sys4 の特異値の計算
figure(3)
semilogx(w,20*log10(sv3),'m--',w,20*log10(sv4),'g--','linewidth',2)
hold off

grid
ylim([-100 20])
set(gca,'fontsize',20,'fontname','arial')
xlabel('frequency [rad/s]','fontsize',22,'fontname','arial')
ylabel('gain [dB]','fontsize',22,'fontname','arial')
set(gca,'xtick',[1e-2 1e-1 1e0 1e1 1e2])
legend('w \rightarrow e','w \rightarrow \theta_{1}','\gamma/{W}_{s}(s)','\gamma/{W}_{t}(s)',3)
set(legend,'fontsize',16,'fontname','arial')

