%   robustness_closedloop.m
amp=1.0;%a=0.1;b=1;
%
%   Closed loop
timespan=[0:0.0001:6];
for a=[0.1 0.2 0.5];
  for b=[0 0.5 1 2];
      %fpmin=0.05;
      fpmin=0.1;
  %a=0.2;b=0.5;fpmin=0.3
ki=1000;
figure(1);
subplot(221)
[t,x,y]=sim('intstat',timespan);
z=rfcn(t,amp);
hold on;
pl=plot(t,y(:,1),'b-');%,t,y(:,2)-y(:,1),'r-');
%set(pl,'Linewidth',1.5);
figure(2);
subplot(221)
plot(y(:,1),y(:,2),'b.');
hold on; 
figure(3)
subplot(221)
plot(t,y(:,2)-y(:,1),'r-');
hold on;
rp=amp*(cos(t)+pi*cos(pi*t)+pi^2*cos(pi^2*t));
pl=plot(t,rp/(ki*fpmin),'b--');
set(pl,'Linewidth',1.5);
end
end
figure(1);
axis([0 2 -1 3])
xlabel('t');ylabel('y');
%amp=1;
%rp=amp*(cos(t)+pi*cos(pi*t)+pi^2*cos(pi^2*t));
%plot(t,rp/(ki*fpmin),'g');
title('b');
print -depsc rob-cl-signals.eps
figure(2)
line([-3 3],[0 0]);
line([0 0],[-3 3]);
axis([-3 3 -3 3]);
axis square
xlabel('x');ylabel('y'); 
title('a');
print -depsc rob-cl-io.eps
figure(3)
axis([0 2 -0.2 0.2])
xlabel('t');ylabel('e');
title('c');
print -depsc rob-cl-error.eps