Resample multiple overlapping datetime to 1-minute (and 15-minutes) resolution?
Show older comments
Coming back again on resampling datetime....
Situation is I have many water pumps which are filled up in different time-frames. I have this table with multiple overlapping time and the total volume of individual pumps. Each row is basically a different water pump.
Column 1 (Start time), Column 2 (End time), Column 3 (Volume)
I want to sample the data to minute resolution (also 15 mins resolution) with the specified volume.
Example:
Pump1: 00:04:34 06:33:34 56
Pump2: 00:10:09 09:50:01 93
What I want it
00:04:00 56
00:05:00 56
....
00:10:00 56+93
00:11:00 56+93
....
06:34:00 93
As you can see, it sums up when there is overlapping time. Or else it is the only volume.
I have attached the actual table as well.
Thanks!
7 Comments
Continuing from https://www.mathworks.com/matlabcentral/answers/476451-resample-datetime-to-minute-resolution
How does this differ from the solution in the previous question (link above)?
Also, where is the overlapping time? Maybe a longer, complete example would be helpful.
Alex
on 21 Aug 2019
That is called a cumulative sum. For example,
example.Volume = cumsum(example.Volume);
Alex
on 21 Aug 2019
Adam Danz
on 21 Aug 2019
The data in your example is all from the same day so it looks like you just need to apply the cumsum() like I showed in my previous comment.
Alex
on 21 Aug 2019
I think I understand now. After you've interpolated the time stamps to minute resolution and replicated the volumne values, (as was demonstrated here), you get a timetable with two columns. Can you just apply the cumulative sum to the "vol" column? I haven't looked too closely as to why that wouldn't work.
[Update]
I think Steven's approach below is the way to go.
Accepted Answer
More Answers (0)
Categories
Find more on Data Preprocessing 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!