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

조회 수: 1 (최근 30일)
Amr Wahdan
Amr Wahdan 2012년 1월 29일
답변: nick 2025년 4월 16일
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
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
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;

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by