The below is the drawing of the mass-spring system with FreeBody
Diagram.
We will solve for the homogeneous (transient) part of the response of
the system, which means the external excitation force is zero.
We will define the natural frequency of the system.
After that, we will set up equation of motion (with FBD and force
balance equation), get the closed form of the solution and try to solve
it using Matlab.
We can write down the equation of motion for this 1 degree of freedom
system with FBD above using force balance.
Click here for details.
Here is Matlab code for the closed form solution.
m = 2; % mass of the system in meter k = 5000; % stiffness of the spring (N/m) wn = sqrt(k/m); % natural frequency (rad/sec) t_final = 3; % calculation time n = 5000; % number of data pointsAt the beginning of the program, we need to write some constant inputs. n is the number of the data points.
xh_0 = 1; % initial displacement for homogeneous solution xh_dot_0 = 0; % initial velocity for homogeneous solutionThen, initial conditions are followed.
X_0 = sqrt(xh_0^2+(xh_dot_0/wn)^2); phi = acos(xh_0/X_0);Calculate the amplitude and the phase angle with given initial conditions.
t = 0:t_final/n:t_final; x = X_0*cos(wn*t+phi); % displacement x(t) x_dot = -wn*xh_0*sin(wn*t+phi); % velocity x_dot(t)And we can determine the displacement x(t) and velocity x_dot(t).
Click here for the entire MATLAB source code for closed form solution.
The displacement x(t) and the velocity v(t) are shown.