modeling a bouncing mass on a elastic surface (spring surface) using .m file
    4 ビュー (過去 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!



