n = 2;

nr = 0;
for om = logspace(0,1,6);
om =1
nr = nr+1;
om2 = 2*om;
sys = zpk([],0*ones(1,n),1);
% s = tf('s');
% sys = 1/s^2
[A,B,C,D] = ssdata(sys);
[Z1,P1,K1] = butter(n,om,'s');
[Z2,P2,K2] = butter(n,om2,'s');
K = place(A,B,P1)
K2 = lqr(A,B,C'*C,1/om^4)
L = place(A',C',P2)'
L2 = lqr(A',C',B*B',1/om2^4)
C1 = ss(A-B*K-L*C,L,K,0);

figure(1)
bode(sys*C1)
hold on;grid on
title('Bode Diagram P*C')

figure(2)
bode(C1)
hold on;grid on
title('Bode Diagram, C')
[mag,phase] = bode(C1);
amp(nr) = max(mag);
S = allmargin(sys*C1);
if ~isempty(S.PMFrequency)
  wgc(nr) = S.PMFrequency(1);
end

figure(4)
[re,im]=nyquist(sys*C1);
plot(squeeze(re),squeeze(im),'Linewidth',2)
set(gca,'Fontsize',16','Fontweight','bold')
axis([-2 2 -2 2])
hold on
grid on
plot(-1,0,'r+','Linewidth',2)

end

figure(3)
loglog(wgc,amp,'r-x','Linewidth',2)
hold on;grid on
set(gca,'Fontsize',16','Fontweight','bold')
xlabel('wgc rad/s')
ylabel('Max |C(iw)|')


% start making note on what you are missing in the matlab control system toolbox

% sisotool

