%% Resample and Aggregate Timetable Data Using Live Editor Task
% The example shows how to resample and aggregate data in a timetable by using the Retime Timetable Live Editor task. You also can apply different rules for adjusting timetable variables in different ways.
%
%% Resample Data
% Create a timetable using column vectors of data. The row times are between 10 and 50 milliseconds.

Intensity = [100 98.7 95.2 101.4 99.1]';
Time = milliseconds([11 20 34 40.3 49.9])';
TT1 = timetable(Time,Intensity);

%
%
% Add the Retime Timetable task to your live script. Resample the data in TT.
% To specify a sample rate of 100 Hz, use the Selection method menus.
% To adjust the data in the Intensity variable by using linear interpolation, use the General rule menus.
%
%
%% Aggregate Data
% Load a second timetable from the bostonTT MAT-file. This timetable has temperature, wind speed, and rainfall measurements for the city of Boston. The measurements are approximately six hours apart but are irregular.

load bostonTT

%
%
% Add a second instance of the Retime Timetable task to your live script. Aggregate the data into daily time bins.
% To specify a time step of one day, use the Selection method menus.
% To calculate means of the timetable variables, use the General rule menus.
% To specify a different rule for the Rain variable, use the Exceptions menu. Add an exception to interpolate rainfall measurements at the beginning of each day.
%
% Copyright 2019 The MathWorks, Inc.