How to find the sum of duration if the consecutive row elements are the same?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a table of datetime Activated and Location
e.g.
'2019-12-08 10:32:26' 'Room 1 '
'2019-12-08 10:33:32' 'Room 2'
'2019-12-08 10:34:35' 'Room 2'
'2019-12-08 10:35:09' ''Room 3'
'2019-12-08 10:36:56' 'Room 3'
'2019-12-08 10:38:24' 'Room 3'
'2019-12-08 10:40:17' 'Room 1'
'2019-12-08 10:43:06' 'Room 1'
'2019-12-08 10:44:28' 'Room 1'
'2019-12-08 10:45:28' 'Room 2'
and I have used diff(table.datetime,1,1) to return a separate duration file of duration spent in each room before the next room is activated
e.g.
'00:01:06'
'00:01:03'
'00:00:34'
'00:01:47'
'00:01:28'
'00:01:53'
'00:02:49'
'00:01:22'
'00:04:02'
'00:07:18'
Now I want to find the duration of time spent in each room, i.e. the start and end time of a repeated train of activations of a single room. E.g. time spent in room 2 would be the duration from 10:33:32 to 10:35:09 (i.e. sum of duration values of same rows in the duration file)
Is there a way to loop through the table and calculate time spent in each room?
0 Kommentare
Siehe auch
Kategorien
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!