FINAL INDEPENDENT PROJECT
Simple Oscilation Motion in Horizontal Spring Mass System.
Oscillates back and forth as well as its position with respect to time can be easily determined. In this lab, you will analyze a simple pendulum and a spring-mass system, both of which exhibit simple harmonic motion.
free body diagram =>
by appling the netwon law of motion
by simpified version of the above equation :
the above equation can be written as in matlab:
Eigenfrequency :
Angular Eigenfrequency
clear all % Delete the Workspace
close all % close all Command
clc % clear the command window
%% Defination
%%
mass = 750; % Mass [kg]
stiffness = 50000; % [N/m]
time = 0:0.01:2; % time[s]
damping = 0;
x_0 = 0.01; % [m]
x_dot_0 = 0.2; % [m/s]
%% Symobolic Function defination
%%
syms x(t) ;
Dx = diff(x,1);
D2x = diff(x,2);
%% Computing
%%
x = dsolve( mass*D2x + damping*Dx + stiffness*x == 0 , x(0) == x_0, Dx(0) == x_dot_0,'t');
%% 2.) Evalute the equations
%%
x_fun = matlabFunction(x);
x_dot_fun = matlabFunction(diff(x));
x_t = x_fun(time);
v_t = x_dot_fun(time);
%% Calculate Amplitude
%%
x_r = max(abs(x_t));
%% Calculate time period
%%
[maxima, max_location] = findpeaks(x_t,time);
time_period = diff(max_location)
%% Calculate eigenfrequency and angular eignfrequency
%%
frequency = 1/time_period(1);
angular_eignfrequency = 2*pi*frequency
%%Calculation phase angle
%%
temp_variable = diff(sign(v_t));
indx_up = find(temp_variable>0);
indx_down = find(temp_variable<0);
indx_up_time = time(indx_up);
indx_down_time = time(indx_down);
first_zero_crossing = min([indx_up_time indx_down_time]);
phase_angle_rad = angular_eignfrequency*first_zero_crossing
phase_angle_degree = 180/pi*phase_angle_rad
%% Plot
%%
yyaxis left
plot(time,x_t,'linewidth',2)
ylabel('displacement')
xlabel('time')
yyaxis right
plot(time,v_t,'linewidth',2)
ylabel('velocity')
#Output


