%% Store and Synchronize Related Data Variables in Timetable
% Store data about weather conditions measured at different times in a timetable. Aside from storage, timetables provide functions to synchronize data to times that you specify. Also, you can annotate the timetable to describe your work and the variables of the timetable.
% Create a timetable from workspace variables. The values in MeasurementTime become the row times of the timetable. All the other input arguments become the timetable variables. When you use this syntax, the names of the row times vector and the variables of TT are the names of the corresponding input arguments.

MeasurementTime = datetime({'2015-12-18 08:03:05';'2015-12-18 10:03:17';'2015-12-18 12:03:13'});
Temp = [37.3;39.1;42.3];
Pressure = [30.1;30.03;29.9];
WindSpeed = [13.4;6.5;7.3];
TT = timetable(MeasurementTime,Temp,Pressure,WindSpeed)

%
% Synchronize the weather data to regular times with an hourly time step. Adjust the data to the new times using linear interpolation.

TT2 = retime(TT,'hourly','linear')

%
% Since the row times of the output are not the measured times, rename the vector of row times. This vector is also the name of the first dimension of the timetable.

TT2.Properties.DimensionNames{1} = 'InterpolatedTimes'

%
% Annotate TT2 with a description. You can annotate TT2 and its variables using metadata accessed through TT2.Properties.

TT2.Properties.Description = 'Weather data, interpolated to regular hourly times';
TT2.Properties

% Copyright 2012 The MathWorks, Inc.