resample
Resamples a timeseries at new time points.
Category: Language Fundamentals > Data Types
Syntax
ts2 = resample(ts, timevec)
Returns ts evaluated at the times in timevec, using the series' interpolation method.
Description
By default the data are interpolated linearly between samples; change this with setinterpmethod, for instance 'zoh' holds each value until the next sample. Times outside the original range are not extrapolated.
To resample a timetable use retime.
Input arguments
ts- A
timeseriesobject. timevec- Vector of new times, in the series' time units.
Output arguments
ts2timeserieswith the new time vector and interpolated data.
Example
ts = timeseries([10 20 30]', [0 1 2]);
r = resample(ts, [0.5 1.5]);
r.Time'
r.Data'
Output
ans = 1×2
0.5000 1.5000
ans = 1×2
15 25