[ts1ts2]
= synchronize(ts1,ts2, synchronizemethod)
creates two new timeseries objects by synchronizing ts1 and ts2 using
a common time vector and the specified method.

[ts1ts2]
= synchronize(ts1,ts2, Name,Value) creates
the two new timeseries objects with additional
options specified by one or more Name,Value pair
arguments.

Input Arguments

ts1

One of the timeseries objects that you want
to synchronize and resample.

ts2

The other timeseries object that you want
to synchronize and resample.

synchronizemethod

A string that defines the method for synchronizing the timeseries object.
It can be any one of the following:

Union — Resample timeseries objects
using a time vector that is a union of the time vectors of ts1 and ts2 on
the time range where the two time vectors overlap.

Intersection — Resample timeseries objects
on a time vector that is the intersection of the time vectors of ts1 and ts2.

Uniform — Requires an additional
argument as follows:

This method resamples time series on a uniform time vector,
where value specifies the time interval between
two consecutive samples. The uniform time vector is the overlap of
the time vectors of ts1 and ts2.
The interval units are the smaller units of ts1 and ts2.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments.
Name is the argument
name and Value is the corresponding
value. Name must appear
inside single quotes (' ').
You can specify several name and value pair
arguments in any order as Name1,Value1,...,NameN,ValueN.

'InterpMethod'

Forces the specified interpolation method (over the default
method) for this synchronize operation. Can be either a string, linear or zoh,
or a tsdata.interpolation object that contains
a user-defined interpolation method.

Default: linear

'QualityCode'

Integer (between -128 and 127) used as the quality code for
both time series after the synchronization.

'KeepOriginalTimes'

Logical value (true or false)
indicating whether the new time series should keep the original time
values.

'tolerance'

Real number used as the tolerance for differentiating two time
values when comparing the ts1 and ts2 time
vectors. The default tolerance is 1e-10. For example,
when the sixth time value in ts1 is 5+(1e-12) and
the sixth time value in ts2 is 5-(1e-13),
both values are treated as 5 by default. To differentiate those two
times, you can set 'tolerance' to a smaller value
such as 1e-15, for example.

Output Arguments

ts1

One of the timeseries objects that you synchronized
and resampled.

ts2

The other timeseries object that you synchronized
and resampled.

Examples

This example illustrates how the KeepOriginalTime property
affects synchronization.

% Create two timeseries, 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)]);
% If you use this code, then ts1.timeinfo.StartDate
% is changed to match ts2.TimeInfo.StartDate
% and ts1.Time changes to 1:
[ts1 ts2] = synchronize(ts1,ts2,'union');
% But if you use this code, then ts1.timeinfo.StartDate
% is unchanged and ts1.Time is still 0:
[ts1 ts2] = synchronize(ts1,ts2,'union','KeepOriginalTimes',true);