% ref_follow.m - following command signals
% KJA, 2012

aminit;					% initialize FBS macros

tstop = 6; t = 0:0.1:tstop;
a = 1; b = 1;

Str = {'b-', 'b--', 'b:'}; jjj = 1;
zc = 0.707;
figure(1);
for wc = [1 2 5],
  kp = (2*zc*wc-a)/b;
  ki = wc^2;
  Gyr = tf([kp ki], [1 2*zc*wc wc^2]);
  y = step(Gyr, t);
  Gur = tf([conv(b*[kp ki], [1 -1])], [1 2*zc*wc wc^2]);
  u = step(Gur, t);
  subplot(321)
  str = Str{jjj}; jjj = jjj+1;
  pl = plot(t, y, str);
  set(pl,  'LineWidth',  AM_data_linewidth);
  amaxis([0 tstop 0 1.5]);
  hold on;

  subplot(323)
  pl = plot(t, u, str);
  set(pl,  'LineWidth',  AM_data_linewidth);
  amaxis([0 tstop -2 5]);
  hold on;
end

subplot(321)
ylabel('y');
subplot(323)
xlabel('t'); ylabel('u');
amprint('ref-follow-w.eps')

figure(2)
wc = 2;
Str = {'b:', 'b--', 'b-'}; jjj = 1;
for zc = [0.5 0.707 1],
    kp = (2*zc*wc-a);
ki = wc^2;
Gyr = tf([kp ki], [1 2*zc*wc wc^2]);
y = step(Gyr, t);
Gur = tf([conv(b*[kp ki], [1 -1])], [1 2*zc*wc wc^2]);
u = step(Gur, t);

subplot(321);
str = Str{jjj}; jjj = jjj+1;
pl = plot(t, y, str);
set(pl,  'LineWidth',  AM_data_linewidth);
amaxis([0 tstop 0 1.5]);
hold on;

subplot(323)
pl = plot(t, u, str);
set(pl,  'LineWidth',  AM_data_linewidth);
amaxis([0 tstop -2 5]);
hold on;
end

subplot(321);
ylabel('y');
subplot(323)
xlabel('t'); ylabel('u');

amprint('ref-follow-z.eps')
