timeseries

Methods

Method Reference: timeseries.resample

timeseries: ts = resample (ts, time)

timeseries: ts = resample (ts, time, method)

timeseries: ts = resample (ts, time, method, code)

Evaluate a series at new times.

ts = resample (ts, time) returns the series ts with its samples replaced by its values at time, found with its own interpolation method. time is numeric, in the series’ units; for a series with a TimeInfo.StartDate it may also be dates, as text or a datetime, and numbers count from the start date. The new times are sorted, repeats kept. Samples that are NaN are left out before interpolating, as in MATLAB; at a time outside the series the data is NaN. The class of the data is kept. Every property but the samples is kept.

ts = resample (ts, time, method) uses method, 'linear' or 'zoh' in any case, instead; [] keeps the series’ own.

ts = resample (ts, time, method, code) gives the quality code code, an integer listed in QualityInfo.Code, to every new time the series did not already hold. [] gives none.

A series with quality codes gives each other new time the code of the nearest sample, a tie going to the later, as MATLAB does; under 'zoh' a value takes the code of the sample it is held from, where MATLAB takes the nearest one’s, which may be the next sample’s. Outside the series a code is the nearest sample’s too, where MATLAB raises for a series with codes. Custom methods are called on the data only.

See also: timeseries.synchronize, timeseries.setinterpmethod

Source Code: timeseries

resample evaluates a series at new times. Outside the series the data is NaN, and each new time takes the quality code of the nearest sample.

 ts = timeseries ([0; 10; 20], [0; 1; 2], [1; 2; 3]);
 s = resample (ts, [0.5, 1.5, 3]);
 [s.Time, s.Data, s.Quality]
ans =

   0.5000   5.0000   2.0000
   1.5000  15.0000   3.0000
   3.0000      NaN   3.0000

A method given here overrides the series' own for this call, and a code, listed in QualityInfo.Code, marks the times the series did not hold.

 ts = timeseries ([0; 10; 20], [0; 1; 2], [1; 1; 1]);
 ts.QualityInfo.Code = [1, 9];
 ts.QualityInfo.Description = {'measured', 'filled'};
 s = resample (ts, 0:0.5:2, 'zoh', 9);
 [s.Time, s.Data, s.Quality]
ans =

         0         0    1.0000
    0.5000         0    9.0000
    1.0000   10.0000    1.0000
    1.5000   10.0000    9.0000
    2.0000   20.0000    1.0000