%% Synchronize Timetables to Regular Times
% Synchronize two small timetables with weather measurements to a set of regular row times that span the row times in the input timetables. Specify a time step as the interval between consecutive row times in the output timetable. Use linear interpolation to resample data for times in the time vector that do not match row times from the input timetables.
% First, load the two timetables.

load indoors
load outdoors

%
% Display the first three lines of each timetable. They do not contain the same row times or variables.

indoors(1:3,:)

%

outdoors(1:3,:)

%
% Aggregate the data from the timetables into 30-minute time bins using the synchronize function. Specify a regular time step using the 'regular' input argument and the 'TimeStep' name-value pair argument. You can use these arguments to create a timetable that is regular, but whose time step is not a predefined step such as 'hourly'.

TT = synchronize(indoors,outdoors,'regular','linear','TimeStep',minutes(30));
TT(1:3,:)

% Copyright 2012 The MathWorks, Inc.