timeseries

Methods

Method Reference: timeseries.synchronize

timeseries: [ts1, ts2] = synchronize (ts1, ts2, method)

timeseries: [ts1, ts2] = synchronize (…, name, value)

Resample two series onto common times.

[ts1, ts2] = synchronize (ts1, ts2, method) resamples both series onto one set of times within the span both cover, chosen by method, matched in any case:

'union'
every time of either series in that span;
'intersection'
the times both series hold, within the tolerance;
'uniform'
times from the start of the span, a step of 'Interval' apart.

Series that do not overlap become series with no samples. Each keeps its own units, the times converted exactly; MATLAB converts them with errors near the tenth digit. Dated series are placed by their start dates, and both results count from the earlier of the two unless 'KeepOriginalTimes' is true. A dated series with an undated one is refused, since the undated one has no calendar; MATLAB then reads both as undated.

The options, matched in any case:

'Interval'
the step of 'uniform', a positive number in the first series’ units, 1 by default; MATLAB accepts zero and negative steps and gives one sample or none.
'InterpMethod'
'linear' or 'zoh', for both series; by default each uses its own.
'QualityCode'
a quality code given to the times each series did not already hold, as for resample.
'KeepOriginalTimes'
true to keep each dated series on its own start date.
'tolerance'
how close two times must be to count as one, in the first series’ units, 1e-10 by default; the second series’ time is kept. This is the documented meaning; MATLAB ignores any tolerance above about 1e-10, so there 0.1 matches no times 0.05 apart, while here it matches them.

Quality codes follow the rules of resample.

See also: timeseries.resample, timeseries.append

Source Code: timeseries

synchronize resamples two series onto common times within the span both cover: the union of their times, their intersection, or a uniform grid.

 a = timeseries ([1; 2; 3], [0; 2; 4]);
 b = timeseries ([10; 20; 30], [1; 2; 3]);
 [a2, b2] = synchronize (a, b, 'union');
 [a2.Time, a2.Data, b2.Data]
ans =

    1.0000    1.5000   10.0000
    2.0000    2.0000   20.0000
    3.0000    2.5000   30.0000
 [a2, b2] = synchronize (a, b, 'uniform', 'Interval', 0.5);
 [a2.Time, a2.Data, b2.Data]
ans =

    1.0000    1.5000   10.0000
    1.5000    1.7500   15.0000
    2.0000    2.0000   20.0000
    2.5000    2.2500   25.0000
    3.0000    2.5000   30.0000