% Main file to execute the mass-spring-damper system

% Solution to a set of eauations      of the form:
%
% ydot(1) = y(2);
% ydot(2) = F(t)/m - k/m y(1) - b/m y(2)
%
% subject to initial conditions:
%
% y (t=0) = yo
%
% where: 


global m b k 

% Define Initial Conditions of the Problem

yo = [0 0];                     % yo are the initial displacement and velocity
to = 0.0;                       % to is the initial time to solve this equation
tf = 15.0;                        % tf is the final time

% define m and b

m = 300;		% mass (N)
b = 200;			% damper constant (N / (m/s))
k = 4000;		% spring constant (N/m)
tspan =[to tf];

[t,y] = ode23('fy',tspan,yo);	% call ODE solver

% Plot the results of the numerical integration procedure

plot(t,y(:,1))
xlabel('Time (seconds)')
ylabel('Position (m)')
grid

pause


plot(t,y(:,2))
xlabel('Time (seconds)')
ylabel('Speed (m/s)')
grid
