File Exchange

image thumbnail

Bouncing Rod Simulator -- ODE45 Event Detection Example

version (5.65 KB) by Matthew Sheen
Simulate a rod bouncing and tumbling with animation.


Updated 25 Jun 2016

From GitHub

View license on GitHub

Video here:

This is an example of how event detection works in MATLAB with integrator ODE45. A simple rod bounces and tumbles on flat ground until it finally begins sliding. This might be helpful to you if you have continuous dynamics with discrete events happening (like collisions).
1. MAIN_simulate.m -- Run this first!
2. deriveCollisions.m -- Derives contact map equations to determine how the rod acts after a collision. This file auto-generates:
* DiscreteCollisionsPt1.m
* DiscreteCollisionsPt2.m
3. slidingPhase.m -- Equations of motion for the sliding rod.
4. flightPhase.m -- Equations of motion for the flying rod.
5. contact.m -- Conditions passed to ODE45 so it can determine when events occur and what to do.
6. animate.m -- Draw the scene and show what happened during the simulation.

Cite As

Matthew Sheen (2021). Bouncing Rod Simulator -- ODE45 Event Detection Example (, GitHub. Retrieved .

Comments and Ratings (2)


Elijah Tapiwa Chipato

Very interesting. Do you have a pdf doc with a description of the problem you are solving? It's difficult to follow particularly, the derivation without that

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!