%% Synchronize timeseries Objects
% Create two timeseries objects such that ts1.timeinfo.StartDate is one day after ts2.timeinfo.StartDate.

ts1 = timeseries([1 2],[datestr(now); datestr(now+1)]);
ts2 = timeseries([1 2],[datestr(now-1); datestr(now)]);

% Change ts1.timeinfo.StartDate to match ts2.timeinfo.StartDate and change ts1.Time to 1.

[ts1 ts2] = synchronize(ts1,ts2,'union');

%
% The following command preserves ts1.timeinfo.StartDate and keeps ts1.Time as 0.

[ts1 ts2] = synchronize(ts1,ts2,'union','KeepOriginalTimes',true);

% Copyright 2012 The MathWorks, Inc.