MATLAB Answers


How can I divide a week of a timetable into hours

Asked by Antonio Melieni on 15 May 2019
Latest activity Commented on by Peter Perkins
on 20 May 2019
is it possible to devide a week of a timetable into 168 hours?
I would need the means of a timetable from monday to sunday on an hourly basis so I can show how its behaving of the week
Thx :)


Please attach your timetable as mat-file.
So what I need is the mean over each of the 168 hours of the week from these data

Sign in to comment.

1 Answer

Answer by Guillaume
on 15 May 2019
 Accepted Answer

hourlytimetable = retime(yourtimetable, 'hourly', 'mean')


Guillaume is correct.
retime can do hourly (or whatever) summaries, but only on a linear time line. You are asking for a cyclic time line. Adding a dummy variable for "hour of week" and grouping on that is the way to go. groupsummary, or splitapply, or varfun would allwork; groupsummary is probably the simplest.
Peter, a suggestion: an option to specify bin indices instead of bin intervals for groupsummary at least. That would avoid having to create the binning variable:
hourofweek = ...
groupsummary(Volatility, 'BinNumbers', hourofweek, 'mean')
Yes, this would be useful in many contexts. Thanks.

Sign in to comment.