modeling a bouncing mass on a elastic surface (spring surface) using .m file
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a problem to create a function using ode45 to plot the movement of bouncing mass on a spring damper system.
댓글 수: 1
Walter Roberson
2012년 1월 29일
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
답변 (1개)
nick
2025년 4월 16일
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;
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!