%% Select Timetable Rows in Specified Time Interval
% Create a timetable that contains times along with measurements of temperature, pressure, and wind speed and direction. Select rows whose times fall within a specified time interval.

Time = datetime({'12/18/2015 08:00:00';'12/18/2015 10:00:0';'12/18/2015 12:00:00';...
                 '12/18/2015 14:00:00';'12/18/2015 16:00:00';'12/18/2015 18:00:00'});
Temp = [37.3;39.1;42.3;45.7;41.2;39.9];
Pressure = [30.1;30.03;29.9;29.8;30.0;29.9];
WindSpeed = [13.4;6.5;7.3;8.5;9.2;4.3];
WindDirection = categorical({'NW';'N';'NW';'NW';'NNW';'N'});
TT = timetable(Time,Temp,Pressure,WindSpeed,WindDirection)

%
% Specify a time range between 12/18/2015 08:00:00 and 12/18/2015 12:00:00.

S = timerange('12/18/2015 08:00:00','12/18/2015 12:00:00')

%
% Select rows with times in the range specified by S. The output timetable includes the start of the time range, but not the end.

TT2 = TT(S,:)

% Copyright 2012 The MathWorks, Inc.