Select or interpolate timeseries data using new time vector
ts1 = resample(ts, time)
ts1 = resample(ts, time, interp_method)
ts1 = resample(ts, time, interp_method, code)
ts1 = resample(ts, time) resamples the timeseries object, ts, using the new time vector. The resample method uses the default interpolation method, which you can view by using the getinterpmethod(ts) syntax.
The timeseries object that you want to resample.
The time vector you want to use to resample the timeseries object.
When ts uses date strings and time is numeric, then time is treated as specified relative to the ts.TimeInfo.StartDate property and in the same units that ts uses.
A string specifying the interpolation method. Valid interpolation methods are linear and zero-order hold, zoh .
An integer value that specifies the user-defined Quality code for resampling. MATLAB applies this Quality code to all samples.
The timeseries object that results when you interpolate the original timeseries object with a new time vector.
This example shows how to resample a timeseries object.
Create a timeseries object.
ts1 = timeseries([1.1; 2.9; 3.7; 4.0; 3.0],1:5,'Name','speed');
View the time, data, and interpolation method.
ts1.time ts1.data ts1.getinterpmethod
Resample ts1 using its default interpolation method.
res_ts=resample(ts1,[1 1.5 3.5 4.5 4.9]);
View the time, data, and interpolation method for the resampled object.
res_ts.time res_ts.data res_ts.getinterpmethod