%Step responses for forward and reverse driving
% kja 070516

aminit;

t=0:0.01:4;
T=0.1;
Gf=tf([1 1],conv([1 0],[T 1]));
Gr=tf([-1 1],conv([1 0],[T 1]));
yf=step(Gf,t);
yr=step(Gr,t);
%
%Step response
figure(1); clf; subplot(221);
pl=plot(t,yf,'b--',t,yr,'b-');
set(pl,'Linewidth', AM_data_linewidth);
hold on
%line([0 4],[0 0]);
% axis([0 4 -1 5])
xlabel('t');
ylabel('y');

lgh = legend('Foward', 'Reverse', 'Location', 'northwest');
legend(lgh, 'boxoff');

amprint('steering-fwdrev-step.eps');

%
%Bode plot
w=logspace(-1,1);
[gf,pf]=bode(Gf,w);gf=gf(:);pf=pf(:);
[gr,pr]=bode(Gr,w);gr=gr(:);pr=pr(:);

figure(2); clf; subplot(221);
[mh, ph] = ambode(Gr, w); hold on;

axes(mh); hold on;
loglog(w, gf, 'b--', 'Linewidth', AM_data_linewidth);
axis([0.1 10 0.1 10]);
ylabel('g')

axes(ph); hold on;
semilogx(w, pf, 'b--', 'Linewidth', AM_data_linewidth);
set(gca,'Ytick',[-270,-180,-90,0]);
axis([0.1 10 -180 0])
xlabel('w');ylabel('p');

amprint('steering-fwdrev-bode.eps');

