Clear Filters
Clear Filters

How can I calculate the overlapping time on a timetable?

3 views (last 30 days)
I have a dataset with the information: Sensor number, Start Time, End Time (Start Time and End Time are the start and end of access to a certain ground station, so basically start is when the ground station start seeing a sensor, and end time is the last time the ground station see the same sensor). See the attached timetable.
I need to calculate what is the longest duration of time that a ground station can see 2 sensors at the same time, the same for 3 sensors and the same for 4 sensors.
I'm thinking I can run through Start Time and check if the time is between the start and stop time of the previous sensor. For example, I would start at the first row and compare each of the following rows to the first one, go to the second row and do the same... Every tme I get a coincidence, I can have a counter, and I can record the start time and the end time of the coincidence, and calculate the elapsed time.
That will involve for loops, and I'm trying to avoid using them. Also, I kind of have the idea on my mind, but I have been unable to implement it, so obviously I'm not quite there yet.
Any ideas?

Answers (1)

Peter Perkins
Peter Perkins on 6 Apr 2023
This might get you started:
>> load('T3.mat')
>> T3.Next1 = [(T3.LOS(1:end-1) > T3.AOS(2:end)); false];
>> T3.Next2 = [(T3.LOS(1:end-2) > T3.AOS(3:end)); false; false]
T3 =
127×4 timetable
AOS SID LOS Next1 Next2
____________________ ___ ____________________ _____ _____
20-Mar-2023 16:00:00 29 20-Mar-2023 16:01:10 false false
20-Mar-2023 16:07:10 25 20-Mar-2023 16:20:54 false false
20-Mar-2023 16:27:05 24 20-Mar-2023 16:40:02 true false
20-Mar-2023 16:30:31 6 20-Mar-2023 16:43:18 true false
20-Mar-2023 16:41:58 22 20-Mar-2023 16:48:06 false false
20-Mar-2023 16:48:30 21 20-Mar-2023 16:58:56 true false
20-Mar-2023 16:50:51 4 20-Mar-2023 16:53:08 false false
20-Mar-2023 17:00:53 16 20-Mar-2023 17:07:07 false false
20-Mar-2023 17:09:17 11 20-Mar-2023 17:17:31 true false
20-Mar-2023 17:10:47 8 20-Mar-2023 17:21:35 true false
20-Mar-2023 17:19:04 17 20-Mar-2023 17:30:30 true false
20-Mar-2023 17:30:05 18 20-Mar-2023 17:36:34 false false
20-Mar-2023 17:38:11 20 20-Mar-2023 17:51:01 false false
20-Mar-2023 17:57:17 31 20-Mar-2023 18:10:53 true false
20-Mar-2023 18:01:24 2 20-Mar-2023 18:14:29 false false
20-Mar-2023 18:17:18 19 20-Mar-2023 18:32:07 false false
20-Mar-2023 18:37:21 22 20-Mar-2023 18:52:02 false false
20-Mar-2023 18:56:19 16 20-Mar-2023 19:10:59 false false
20-Mar-2023 19:17:32 17 20-Mar-2023 19:31:06 false false
: : : : :
21-Mar-2023 12:42:38 23 21-Mar-2023 12:56:06 false false
21-Mar-2023 12:58:00 5 21-Mar-2023 13:06:43 true false
21-Mar-2023 13:01:18 10 21-Mar-2023 13:15:25 false false
21-Mar-2023 13:21:29 14 21-Mar-2023 13:33:29 true false
21-Mar-2023 13:31:47 4 21-Mar-2023 13:43:56 true true
21-Mar-2023 13:35:44 21 21-Mar-2023 13:43:34 true false
21-Mar-2023 13:43:00 12 21-Mar-2023 13:54:13 false false
21-Mar-2023 13:54:14 11 21-Mar-2023 14:04:26 true false
21-Mar-2023 13:58:32 8 21-Mar-2023 14:05:41 false false
21-Mar-2023 14:13:40 18 21-Mar-2023 14:24:49 false false
21-Mar-2023 14:26:54 15 21-Mar-2023 14:28:53 false false
21-Mar-2023 14:32:37 29 21-Mar-2023 14:46:15 false false
21-Mar-2023 14:52:19 25 21-Mar-2023 15:07:01 false false
21-Mar-2023 15:11:46 24 21-Mar-2023 15:26:35 true false
21-Mar-2023 15:15:07 6 21-Mar-2023 15:29:55 false false
21-Mar-2023 15:30:50 4 21-Mar-2023 15:43:57 true false
21-Mar-2023 15:32:00 21 21-Mar-2023 15:46:32 false false
21-Mar-2023 15:51:52 11 21-Mar-2023 16:00:00 true false
21-Mar-2023 15:54:27 8 21-Mar-2023 16:00:00 false false
Display all 127 rows.

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!