%Limitations due to RHP pole and zero and RHP pole and time delay
%   kja 070703

aminit;					% initialize MATALB

figure(1); clf;

w=logspace(-2,2);
s=i*w;
%
%   Pole and zero in the RHP zero faster than pole
b=1;
subplot(221)
for a=[2 5 20 100];
  Ppz=(a-s).*(s+b)./(a+s)./(s-b);
  semilogx(w, 180*angle(Ppz)/pi, 'Linewidth', AM_bode_linewidth);
  hold on;
end
amtext(15, -15, '{\itb}=100');
amtext(7, -47, '{\itb}=20');
amtext(5, -103, '{\itb}=5');
% amtext(1.5, -130, '{\itb}=2');

%   Pole and zero in the RHP zero slower than pole
subplot(221);
for a=[1/2 1/5 1/20 1/100];
  Ppz=(a-s).*(s+b)./(a+s)./(s-b);
  semilogx(w, -180*angle(Ppz)/pi, 'b--', 'Linewidth', AM_bode_linewidth);
  hold on;
end
amtext(0.015, -15, '{\itb}=0.01');
amtext(0.035, -47, '{\itb}=0.05');
amtext(0.055, -103, '{\itb}=0.2');
% amtext(0.1, -130, '{\itb}=0.5');

plot([0.01 100], [-90 -90], 'k', 'LineWidth', AM_ref_linewidth);
amaxis([0.01 100 -180 0]);
set(gca,'Ytick',[-180 -90 0])
xlabel('w');ylabel('p')

amprint('limitations-rhppz.eps');

%
%   Pole in the RHP and time delay
b=1;
figure(2); clf; subplot(221)

for T=[0.02 0.1 0.5 1]
  Ppz=(s+b).*exp(-s*T)./(s-b);
  pl=semilogx(w,180*unwrap(angle(Ppz))/pi);hold on;
  set(pl,'Linewidth',AM_bode_linewidth)
end
amtext(10, -12, '\tau=0.02');
amtext(4.5, -40, '\tau=0.1');
amtext(1.8, -100, '\tau=0.5');
amtext(1.1, -138, '\tau=1');

plot([0.01 100], [-90 -90], 'k', 'LineWidth', AM_ref_linewidth);
amaxis([0.01 100 -180 0]);
set(gca,'Ytick',[-180 -90 0])
xlabel('w');ylabel('p')

amprint('limitations-rhpdel.eps');
