modeling a bouncing mass on a elastic surface (spring surface) using .m file

1 visualización (últimos 30 días)
Amr Wahdan
Amr Wahdan el 29 de En. de 2012
Respondida: nick el 16 de Abr. de 2025
I have a problem to create a function using ode45 to plot the movement of bouncing mass on a spring damper system.
  1 comentario
Walter Roberson
Walter Roberson el 29 de En. de 2012
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

Iniciar sesión para comentar.

Respuestas (1)

nick
nick el 16 de Abr. de 2025
Hello Amr,
As Walter pointed out, kindly share the issue and the code that you tried to help you debug the issue.
To model a general bouncing mass on an elastic surface using a spring-damper system, you can describe the system using a second-order differential equation derived from Newton's second law. The spring-damper system can be characterized by the following equation:
m = 1.0; % Mass (kg)
k = 10.0; % Spring constant (N/m)
c = 0.5; % Damping coefficient (Ns/m)
g = 9.81; % Acceleration due to gravity (m/s^2)
y0 = [0.1; 0]; % Initial displacement (m) and velocity (m/s)
tspan = [0 10]; % Time from 0 to 10 seconds
% Define the function handle for the ODE
bouncingMass = @(t, y) [y(2); (-k/m)*y(1) - (c/m)*y(2) + g];
[t, y] = ode45(bouncingMass, tspan, y0);
figure;
subplot(2, 1, 1);
plot(t, y(:, 1), 'b-');
xlabel('Time (s)');
ylabel('Displacement (m)');
title('Displacement vs. Time');
grid on;
subplot(2, 1, 2);
plot(t, y(:, 2), 'r-');
xlabel('Time (s)');
ylabel('Velocity (m/s)');
title('Velocity vs. Time');
grid on;

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by