Quantcast

Documentation Center

  • Trial Software
  • Product Updates

resample

Class: timeseries

Select or interpolate timeseries data using new time vector

Syntax

ts1 = resample(ts, time)
ts1 = resample(ts, time, interp_method)
ts1 = resample(ts, time, interp_method, code)

Description

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

ts

The timeseries object that you want to resample.

time

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.

interp_method

A string specifying the interpolation method. Valid interpolation methods are linear and zero-order hold, zoh .

Default: linear

code

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

Output Arguments

ts1

The timeseries object that results when you interpolate the original timeseries object with a new time vector.

Examples

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

See Also

| | |

Was this topic helpful?