In: Physics
The mass of 100 g hangs in a spring with the spring constants 40 N / m. The pulp is swung by the spring being stretched 14 mm. Neglect all energy losses.
a) Use MatLab and draw a chart showing the distance from equilibrium mode as a function of time with the initial conditions x (0) = 14 mm and v (0) = 0 mm / s
b) Determine speed as a function of time.
MATLAB PROGRAM: put damping constant=0 as there is no loss of energy.
Put spring constant value=40 and m=0.1 kg
%Program Body
clear
clc
t= linspace(0,70);
%Input
prompt= 'For damped oscillation consider the following forces
F1=-
b*v and F2=k*x. Insert the mass of the particle, damping constant
b
and the spring force constant k \n';
m= input(prompt);
b= input(prompt);
k= input(prompt);
prompt = 'Insert the initial position of particle \n';
a= input(prompt);
%Defining functions
T= 2*m/b;
w= sqrt((k/m)-(b.^2/(4*m.^2)));
f= a*cos(w*t).*exp(-t/T);
v= gradient(f);
A= gradient(gradient(f));
K=0.5.*m.*(v.^2);
p=(0.5).*k.*(f.^2);
E= K+p;
%Obtaing the required subplots
%Displacement
subplot(2,2,1);
t= linspace(0,70);
plot(t,f);
title('Subplot 1: Displacement');
ylabel('Displacement');
xlabel('Time');
grid on;
grid minor;
%Velocity
subplot(2,2,2);
t= linspace(0,70);
plot(t,v);
title('Subplot 2: Velocity');
ylabel('Velocity');
xlabel('Time');
grid on;
grid minor;
Energy
subplot(2,2,4);
t= linspace(0,70);
plot(t,E);
title('Subplot 4: Energy');
ylabel('Energy');
xlabel('Time');
grid on;
grid minor;
%Program-end