%% Synchronize Timetables Using Multiple Methods
% Synchronize two timetables. Apply the mean method to some timetable variables and the sum method to others.
% Load two small timetables that contain weather measurements for Boston and Natick. Each timetable contains temperature and rainfall readings.

load citiesTT
Boston

%

Natick

%
% Synchronize the measurements to daily times to produce mean temperatures and the sums of the rainfall measurements. synchronize applies the specified method to all timetable variables. To apply different methods to different timetable variables, index into the timetables to select different variables, and call synchronize for each method you use.

BOS = Boston(:,'Temp');
NTK = Natick(:,'Temp');
TT1 = synchronize(BOS,NTK,'daily','mean')

%

BOS = Boston(:,'Rain');
NTK = Natick(:,'Rain');
TT2 = synchronize(BOS,NTK,'daily','sum')

%
% To combine all results in one timetable, concatenate TT1 and TT2.

TT = [TT1 TT2]

% Copyright 2012 The MathWorks, Inc.