How can I count how many times the position of a bouncing ball on the simulator hits 0?
28 views (last 30 days)
Show older comments
I'm using MathWorks' sample simulink model for a bouncing ball and I wanted to know if there is any way to calculate how many times the position hits 0 when simulating the model. I'm have just begun using Matlab and Simulink so I'm sorry if it is something obvious. Anyway thanks in advance! (included a printscreen of the model in case anyone wanted to know which one it was)
0 Comments
Answers (1)
Paul
on 9 Sep 2021
Edited: Paul
on 9 Sep 2021
Drag a Triggered Subsystem into the diagram.
Connect the output of the <=0 block to the trigger input of the Triggered Subsystem
The inside of the Triggered Subsystem should look like this:
Double click the Memory block, check the box for Inherit Sample Time.
The output of the Triggered Subsystem is the bounce count.
Comment: Initializing the ball at 0 does not count as bounce.
0 Comments
See Also
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!