b=1;
a=1;
z0=0.5;

omv=logspace(-1,1,25);;
risetime=[];
maxd=[];
maxu=[];
for om=omv
  P=tf(b,[1 a]);
  kp=2*z0*om-1;
  ki=om^2;
  C=tf([kp ki],[1 0]);
  u = step(C/(1+P*C),0:0.01:100);
  [y,t] = step(P*C/(1+P*C),0:0.01:100);
  d = step(P/(1+P*C),0:0.01:100);
  risetime = [risetime max(t(find(abs(y-1)>0.05)))];
  maxd = [maxd max(abs(d))];
  maxu = [maxu max(abs(u))];
end

figure(1)
plot(omv,risetime,'Linewidth',2)
xlabel('omega_0','FontSize',16)
ylabel('risetime','FontSize',16)
set(gca,'Fontsize',16','Fontweight','bold')

figure(2)
plot(omv,maxd,'Linewidth',2)
xlabel('\omega_0','FontSize',16)
ylabel('input load disturbance peak','FontSize',16)
set(gca,'Fontsize',16','Fontweight','bold')

figure(3)
plot(omv,maxu,'Linewidth',2)
xlabel('omega_0','FontSize',16)
ylabel('control signal peak','FontSize',16)
set(gca,'Fontsize',16','Fontweight','bold')

for om=[10 3 1 0.3 0.1];
  b=1.1;
  P=tf(b,[1 a]);
  kp=2*z0*om-1;
  ki=om^2;
  C=tf([kp ki],[1 0]);

  figure(4)
  [y,t]=step(P*C/(1+P*C),0:0.01:100);
  plot(t,y,'Linewidth',2)
  hold on
  title('step response with G=1.1/(s+1), omega_0=[0.1 0.3 1 3 10]','FontSize',16)
  set(gca,'Fontsize',16','Fontweight','bold')
end

figure(5)
[re,im]=nyquist(P*C);
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)

