%   ff_simp.m
%   Illustration of feedforward compensation
%   kja 2012

aminit;					% initialize FBS macros

s=tf([1 0],1);
z=0.707;
str='b-';
%
wc=1;tmax=10;dt=tmax/100;t=0:dt:tmax;
Gm=wc^2/(s^2+2*z*wc*s+wc^2);
G=wc^2*(s+1)/(s^2+2*z*wc*s+wc^2);
ym=step(Gm,t);
uff=step(G,t);
subplot(331)
pl = plot(t, ym, str);
set(pl,  'LineWidth',  AM_data_linewidth);
ylabel('y');
amaxis([0 tmax 0 1.2]);
subplot(334)
pl = plot(t, uff, str);
set(pl,  'LineWidth',  AM_data_linewidth);
xlabel('t');
ylabel('uff');
amaxis([0 tmax 0 1.2]);
amprint('ff-simp-wc1.eps');

%
wc=10;tmax=1;dt=tmax/100;t=0:dt:tmax;
Gm=wc^2/(s^2+2*z*wc*s+wc^2);
G=wc^2*(s+1)/(s^2+2*z*wc*s+wc^2);
ym=step(Gm,t);
uff=step(G,t);
subplot(331)
pl = plot(t, ym, str);
set(pl,  'LineWidth',  AM_data_linewidth);
ylabel('y');
amaxis([0 tmax 0 1.2]);
subplot(334)
pl = plot(t, uff, str);
set(pl,  'LineWidth',  AM_data_linewidth);
xlabel('t');
ylabel('uff');
amaxis([0 tmax 0 5.5]);
amprint('ff-simp-wc10.eps')
%
wc=100;tmax=0.1;dt=tmax/100;t=0:dt:tmax;
Gm=wc^2/(s^2+2*z*wc*s+wc^2);
G=wc^2*(s+1)/(s^2+2*z*wc*s+wc^2);
ym=step(Gm,t);
uff=step(G,t);
subplot(331)
pl = plot(t, ym, str);
set(pl,  'LineWidth',  AM_data_linewidth);
ylabel('y');
amaxis([0 tmax 0 1.2]);
subplot(334)
pl = plot(t, uff, str);
set(pl,  'LineWidth',  AM_data_linewidth);
xlabel('t');
ylabel('uff');
amaxis([0 tmax -5 50]);
amprint('ff-simp-wc100.eps')
