% cruise_linsim.m - simulation of linear model with PI control
% kja 060727

aminit;
cruise_lin               %Get parameters of linear model

w0=0.5;
t=0:0.1:40;
%Generate input
u=max(0,t-5);u=min(u,1);
dd=u*4*pi/180;

%Sweep over parameter w0
for z0=[0.5 1 2],

%Compute controller parameters
k=(a+2*z0*w0)/b;
ki=w0^2/b;
den=[1 2*z0*w0 w0^2];
v=-lsim(bg*[1 0],den,dd,t);
u=lsim(bg*[k ki],den,dd,t);
subplot(321)
pl=plot(t,v);
set(pl,'Linewidth', AM_data_linewidth);
hold on
subplot(323)
pl=plot(t,u,'b');
set(pl,'Linewidth', AM_data_linewidth);
hold on
end

subplot(321); amaxis([0 40 -2 0.5]);
arcarrow([11.5 -0.8], [6.5, 0.1], -80);
amtext(11.5, -0.9, 'zeta');
ylabel('v');

subplot(323); amaxis([0 40 0 0.801]);
arcarrow([12 0.7], [9, 0.4], 40);
amtext(13, 0.725, 'zeta');
ylabel('throttle');
xlabel('t');

amprint('cruise-conpar-zsweep.eps');
