clear;M=1000;K=100000;A=10;
M=M/4;for B=[20000 10001 5000];
%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);
Y=A*A1/p1*(exp(p1*t)-1);
Y=Y+A*A2/p2*(exp(p2*t)-1);
subplot(211),plot(t,Y),
axis([0 0.5 0 15]),hold on,end
