clear;M=1000;K=100000;A=10;
W=1;V=5;T=W/V;%pothole parameters.
M=M/4;for B=[10001 2000];
%Use formulae from the text.
a1=B/M;a2=K/M;b1=B/M;b2=K/M;
wo=sqrt(a2);aa=a1/2;xi=aa/wo;
p1=wo*(-xi+sqrt(xi*xi-1));
p2=wo*(-xi-sqrt(xi*xi-1));
A1=(b1*p1+b2)/(p1-p2);
A2=-(b1*p2+b2)/(p1-p2);
t=linspace(0,0.5,1000);
S=A*A1/p1*(exp(p1*t)-1);
S=S+A*A2/p2*(exp(p2*t)-1);
%Pothole travel time:
D=round(1000/0.5*T);DD=1000-D;
Y=-S+[zeros(1,D) S(1:DD)];
subplot(211),plot(t,Y),
axis([0 0.5 -20 10]),hold on,end