Define an event if there are > 5 signals detected in a minute
2 views (last 30 days)
Show older comments
Butterflyfish
on 6 Sep 2021
Commented: Butterflyfish
on 3 Mar 2022
I have a datetime table containing detected 'signals' and their variables, including their exact timestamps.
I would like to define an 'event' if 5 or more signals are detected within a minute.
How could I implement this?
Many thanks for any help
[Edit: Here is a sample of my initial table. Signals are designated by type = 1. I need 5 or more signals in a minute to create an 'event']
DT = datetime ({'25-Jul-2018 00:00:03';'25-Jul-2018 00:00:07';'25-Jul-2018 00:00:07';...
'25-Jul-2018 00:00:07';'25-Jul-2018 00:00:18';'25-Jul-2018 00:00:51';...
'25-Jul-2018 00:00:51';'25-Jul-2018 00:00:52';'25-Jul-2018 00:00:53';...
'25-Jul-2018 00:01:05';'25-Jul-2018 00:01:12';'25-Jul-2018 00:01:18';...
'25-Jul-2018 00:01:32';'25-Jul-2018 00:01:34';'25-Jul-2018 00:01:36';...
'25-Jul-2018 00:01:38';'25-Jul-2018 00:01:38';'25-Jul-2018 00:01:38';...
'25-Jul-2018 00:01:39';'25-Jul-2018 00:01:40';'25-Jul-2018 00:01:49';...
'25-Jul-2018 00:01:52';'25-Jul-2018 00:01:54';'25-Jul-2018 00:01:54';...
'25-Jul-2018 00:01:55';'25-Jul-2018 00:01:56';'25-Jul-2018 00:02:05';...
'25-Jul-2018 00:02:09';'25-Jul-2018 00:02:22';'25-Jul-2018 00:02:24';...
'25-Jul-2018 00:02:26';'25-Jul-2018 00:02:33';'25-Jul-2018 00:02:42';...
'25-Jul-2018 00:02:46';'25-Jul-2018 00:02:50';'25-Jul-2018 00:02:51';...
'25-Jul-2018 00:02:51';'25-Jul-2018 00:03:22';'25-Jul-2018 00:03:22';...
'25-Jul-2018 00:03:25';'25-Jul-2018 00:03:25';'25-Jul-2018 00:03:28';...
'25-Jul-2018 00:03:30';'25-Jul-2018 00:03:35';'25-Jul-2018 00:03:38';...
'25-Jul-2018 00:03:41';'25-Jul-2018 00:04:09';'25-Jul-2018 00:04:14';...
'25-Jul-2018 00:04:29';'25-Jul-2018 00:04:30';'25-Jul-2018 00:04:39';...
'25-Jul-2018 00:04:40';'25-Jul-2018 00:04:48';'25-Jul-2018 00:04:55';...
'25-Jul-2018 00:04:55';'25-Jul-2018 00:04:55';'25-Jul-2018 00:04:55';...
'25-Jul-2018 00:04:56';'25-Jul-2018 00:04:57';'25-Jul-2018 00:04:58';...
'25-Jul-2018 00:05:01';'25-Jul-2018 00:05:01';'25-Jul-2018 00:05:02';...
'25-Jul-2018 00:05:04';'25-Jul-2018 00:05:06';'25-Jul-2018 00:05:11';...
'25-Jul-2018 00:05:26';'25-Jul-2018 00:05:27';'25-Jul-2018 00:05:28';...
'25-Jul-2018 00:05:29';'25-Jul-2018 00:05:32';'25-Jul-2018 00:05:35'});
Type = [0;0;1;0;0;0;1;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;0;1;1;1;1;1;1;0;0;0;0;...
0;1;1;0;0;0;0;0;0;0;1;1;1;1;1;1;1;0;0;0;0;0;0;0;0;0;1;0;1;0;0;0;0;1;1;0;...
0;1;1];
TT1 = timetable(DT,Type);
0 Comments
Accepted Answer
Peter Perkins
on 2 Mar 2022
I'm going to assume that "I would like to define an 'event' if 5 or more signals are detected within a minute." and "check if there is an event outside of 'regular' time periods" means that you want a trailing one-minute moving window. Otherwise this is trivial using retime.
movsum can do this:
>> TT1 = retime(TT1,unique(TT1.DT),"sum"); % get rid of duplicate times by summing
>> TT1.Event = (movsum(TT1.Type,[minutes(1) 0],['SamplePoints'],TT1.DT) > 4)
TT1 =
59×2 timetable
DT Type Event
____________________ ____ _____
25-Jul-2018 00:00:03 0 false
25-Jul-2018 00:00:07 1 false
25-Jul-2018 00:00:18 0 false
25-Jul-2018 00:00:51 1 false
25-Jul-2018 00:00:52 0 false
25-Jul-2018 00:00:53 0 false
25-Jul-2018 00:01:05 0 false
25-Jul-2018 00:01:12 0 false
25-Jul-2018 00:01:18 0 false
25-Jul-2018 00:01:32 1 false
25-Jul-2018 00:01:34 1 false
25-Jul-2018 00:01:36 1 false
25-Jul-2018 00:01:38 0 false
25-Jul-2018 00:01:39 0 false
25-Jul-2018 00:01:40 0 false
25-Jul-2018 00:01:49 0 false
25-Jul-2018 00:01:52 0 false
25-Jul-2018 00:01:54 1 false
25-Jul-2018 00:01:55 1 true
25-Jul-2018 00:01:56 1 true
25-Jul-2018 00:02:05 1 true
25-Jul-2018 00:02:09 1 true
25-Jul-2018 00:02:22 1 true
25-Jul-2018 00:02:24 0 true
[snip]
25-Jul-2018 00:03:38 1 false
25-Jul-2018 00:03:41 1 true
25-Jul-2018 00:04:09 1 false
25-Jul-2018 00:04:14 1 true
25-Jul-2018 00:04:29 1 true
25-Jul-2018 00:04:30 1 true
25-Jul-2018 00:04:39 0 true
25-Jul-2018 00:04:40 0 true
25-Jul-2018 00:04:48 0 false
25-Jul-2018 00:04:55 0 false
25-Jul-2018 00:04:56 0 false
25-Jul-2018 00:04:57 0 false
25-Jul-2018 00:04:58 1 true
25-Jul-2018 00:05:01 1 true
25-Jul-2018 00:05:02 0 true
25-Jul-2018 00:05:04 0 true
25-Jul-2018 00:05:06 0 true
25-Jul-2018 00:05:11 0 true
25-Jul-2018 00:05:26 1 true
25-Jul-2018 00:05:27 1 true
25-Jul-2018 00:05:28 0 true
25-Jul-2018 00:05:29 0 true
25-Jul-2018 00:05:32 1 true
25-Jul-2018 00:05:35 1 true
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!