%% Interpolate Data When Synchronizing Timetables
% Synchronize two timetables to a time vector that is the union of all row times from both timetables. Interpolate to fill in missing elements in the output timetable.
% Load timetables that contain two different sets of environmental measurements, airQual and outsideWeather. The air quality data come from a sensor inside a building, while the weather measurements come from sensors outside. The timetables include measurements taken from November 15, 2015, to November 19, 2015.

load insideAirQuality
load outsideWeather

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

airQual(1:3,:)

%

outsideWeather(1:3,:)

%
% Synchronize the timetables to a vector of times that contains all row times from both timetables. Specify 'union' to create the row times for the output timetable. Specify 'linear' to fill in missing timetable elements with linear interpolation.

TT = synchronize(airQual,outsideWeather,'union','linear');
TT(1:6,:)

% Copyright 2012 The MathWorks, Inc.