How to count events in sliding time window

7 次查看(过去 30 天)
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,2:34
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