MATLAB Answers

How can I count how many times the position of a bouncing ball on the simulator hits 0?

조회 수: 5(최근 30일)
Enzo Amaral
Enzo Amaral 2021년 9월 9일
편집: Paul 2021년 9월 9일
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)

답변(1개)

Paul
Paul 2021년 9월 9일
편집: Paul 2021년 9월 9일
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.

Community Treasure Hunt

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

Start Hunting!

Translated by