% Chapter 2: Figure 2.45
%   Unforced Response to an Initial Condition
%   Generates Figure 2.46: Spring-mass-damper unforced response.
%
y0=0.15;
wn=sqrt(2);
zeta=1/(2*sqrt(2));
t=[0:0.1:10];
%
c=(y0/sqrt(1-zeta^2));
y=c*exp(-zeta*wn*t).*sin(wn*sqrt(1-zeta^2)*t+acos(zeta));
%
% Boundary Function
%
bu=c*exp(-zeta*wn*t);bl=-bu;
%
% Plot Unforced Response 
%
plot(t,y,t,bu,'k--',t,bl,'k--'),grid
xlabel('Time (s)'),ylabel('y(t) (m)')
legend(['\omega_n=',num2str(wn),'    \zeta=',num2str(zeta)])
