How can I aggregate rows by a specified start time and time step in a time table?

3 vues (au cours des 30 derniers jours)
I have 15-minute schedules and I want to aggregate time steps with given start time using mean, sum, max, and so on. I've already tried to use the retime function, but it only makes the sum to the next full hour and I need the sum of the next hour. For instance the sum of Load for the next hour starting at 14:30 and including the time steps 14:45, 15:00, 15:15 ...
TStep = hours(1);
AggregateSchedule = retime(Schedule,'regular','sum','TimeStep',TStep);
DateTime ID Load RL Price
___________________ __________ ____ __ _____
14.06.2018 14:30:00 7617 6148 0 250
14.06.2018 14:45:00 7617 6253 0 250
14.06.2018 15:00:00 7617 6358 0 250
14.06.2018 15:15:00 7617 6463 0 250
14.06.2018 15:30:00 7617 6568 0 250
14.06.2018 15:45:00 7617 6673 0 250
14.06.2018 16:00:00 7617 6778 0 250
14.06.2018 16:15:00 7617 6883 0 250
Many thanks in advance!

Réponse acceptée

Guillaume
Guillaume le 14 Juin 2018
My suggestion would be to subtract 30 minutes from your datetime column, retime it as you've done then add the 30 minutes back:
Schedule.Properties.RowTimes = Schedule.Properties.RowTimes - minutes(30);
AggregateSchedule = retime(Schedule, 'hourly', 'sum');
AggregateSchedule.Properties.RowTimes = AggregateSchedule.Properties.RowTimes + minutes(30);
  2 commentaires
s.h.m_89
s.h.m_89 le 20 Juin 2018
Modifié(e) : s.h.m_89 le 20 Juin 2018
Many thanks for your workaround Guillaume!
I also found another solution, described in the following link:
https://de.mathworks.com/matlabcentral/answers/352778-would-be-possible-to-calculate-half-hour-average-by-using-retime
Peter Perkins
Peter Perkins le 3 Juil 2018
Modifié(e) : Peter Perkins le 5 Juil 2018
As I suspect that link describes, retime will happily aggregate on the half-hours, it's just a little bit more work than using 'hourly'. Create an explicit target time vector as something like
target = datetime(2018,6,14,14,30,0):minutes(30):datetime(...)
Also, beginning in R2018a, there's a new syntax to make that easier:
tt = retime(tt,'regular',method,'TimeStep',minutes(30))

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by