%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     MATLAB Solution for Sample Problem 8/6      %
%              by Brian D. Harper                 %
%          The Ohio State University              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%This MATLAB script solves sample problem 8/6 from 
%Engineering Mechanics: Dynamics (5th Edition) by J.L. 
%Meriam and L.G. Kraige, Wiley, 2001.
%For more MATLAB solutions to problems from this text 
%see the supplement: Solving Dynamics Problems in MATLAB 
%by B. D. Harper, Wiley, 2001.

%Before going through this script you should first 
%(1) study the solution to this sample problem in 
%your text and (2) download and study the associated 
%computer extension problem. You should be able to 
%obtain the pdf file for the extension problem from 
%the same web page where you downloaded this MATLAB file.

%%%%%%%%%%%%%%%% Script %%%%%%%%%%%%%%%%%%%%%
% This script plots x versus t for the three
% sets of initial conditions
x = inline('C*sin(24.2*t+psi)*exp(-13.68*t)+.01938*sin(30*t-1.724)')
x = vectorize(x);
t = 0:0.001:0.5;
plot(t,x(.259,.271,t),t,x(.081,1.017,t),t,x(-.178,-.4,t))
xlabel('t (sec)')
ylabel('x (ft)')
legend('xdot_0 = 5 ft/s','xdot_0 = 0 ft/s','xdot_0 = -5 ft/s')
%%%%%%%%%%%%% end of script %%%%%%%%%%%%%%%%%%