How to count events in sliding time window

조회 수: 3 (최근 30일)
vishwajit jadhav
vishwajit jadhav 2018년 11월 8일
답변: Amish 2025년 2월 5일
I want to set the flag if 3 events occurs within 30 seconds(sliding window). How to implement it in simulink? Eg. 1st event occurs timer should start and if 3rd event occurs within 30 seconds then raise the flag. If the time span is less than 30 seconds between 2nd & 4th then also raise the flag.

답변 (1개)

Amish
Amish 2025년 2월 5일
Hi Vishwajit,
To implement a sliding window mechanism in Simulink that raises a flag if three events occur within a 30-second window, you can use a combination of various Simulink blocks to manage event counting and timing. You will needd to implement the following:
  1. Event Detection: Use an Event Trigger block or a logical condition block to detect the occurrence of an event. This block should output a pulse or a logical 1 whenever an event occurs.
  2. Counter: To count the number of events. This counter should increment every time an event is detected.
  3. Timer: Use a Clock block to keep track of the simulation time. Use a Triggered Subsystem or a Stateflow chart to implement the timing logic. This subsystem should start timing when the first event occurs.
  4. Sliding Window Logic: This will be the implementation logic for Stateflow chart.
You can model the logic on the following lines:
  1. Start a timer when the first event occurs.
  2. Check if the count of events reaches three within 30 seconds.
  3. Reset the timer and counter if the 30-second window expires without reaching three events.
  4. Continue counting events and checking the 30-second condition as new events occur.
For more information you can refer to the documentation :
I hope this gives you an idea.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by