This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Class: timeseries

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.

ts1 = resample(ts, time, interp_method) resamples the timeseries object ts using the specified interpolation method, interp_method.

ts1 = resample(ts, time, interp_method, code) resamples the timeseries object ts using the interpolation method given by the string interp_method. MATLAB® applies the code to all samples.

Input Arguments


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 .

Default: linear


An integer value that specifies the user-defined Quality code for resampling. MATLAB applies this Quality code to all samples.

Output Arguments


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.


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.


Introduced before R2006a

Was this topic helpful?