%% Include Right Edges of Time Bins
% Bin timetable data into hourly bins. Specify the right edges, or end times, of the time bins as row times. By default, the left edges, or start times of the time bins, are row times.
% Create a timetable with temperature and pulse readings taken at fifteen minutes intervals.

Time = [minutes(15):minutes(15):minutes(105)]';
Temp = [97.5;97.9;98.1;97.9;98;98.3;97.8];
Pulse = [75;73;68;69;65;72;71];
TT = timetable(Time,Temp,Pulse)

%
% Calculate the mean for each reading over hourly time bins. Specify that the row times of the output timetable are the right edges of the time bins. Since the right edges are included, the reading at 60 minutes is included in the first time bin.

TT2 = retime(TT,'hourly','mean','IncludedEdge','right')

%
% Calculate the means, with the left edges as the row times. The mean values are different from those in TT2, because the reading at 60 minutes is now in the second time bin.

TT3 = retime(TT,'hourly','mean')

% Copyright 2012 The MathWorks, Inc.