Editor's Note: This file was selected as MATLAB Central Pick of the Week
Simulation of a ball bouncing over hilly terrain in 2D. Designed as a tutorial for event detection in Matlab.
Matthew Kelly (2021). Bouncing-Ball: Tutorial for ode45 events. (https://github.com/MatthewPeterKelly/Bouncing_Ball_Matlab), GitHub. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Hi Mohamed, the code for the interactive graphics was written by Jira Doke at Mathworks, which he provides in the comments on the bottom of Pick of the Week page:
http://blogs.mathworks.com/pick/2016/03/04/bouncing-ball-animation-using-events-with-ode/
Is it possible to send me the updated code with the interactive part demonstrated in the video here http://blogs.mathworks.com/pick/2016/03/04/bouncing-ball-animation-using-events-with-ode/?
My email is moh_hesh@hotmail.com
Thank you, much appreciated!
Thanks! I made the ground a set of smooth analytic functions so that the root-solving in the event detection would behave nicely, and so I didn't have to worry about the domain of the function. That being said, as long as ground height is a valid smooth function it the code should run fine.
I could imagine a new implementation of the groundHeight() function that uses a cubic spline to interpolate a set of discrete data, rather than using sine waves. I don't have time to code it up now, but I'm happy to look at pull requests to the GitHub repo if you end up adding that feature.
Excellent! Why not update the function 'groundHeight' so that you can deal with discrete data of ground?(I'm looking forward to an 'interpolation' of every kind of ground :D).