Documentation

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. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

resample

Resample timeseries time vector

Syntax

tsout = resample(tsin,timevec)
tsout = resample(tsin,timevec,interpmethod)
tsout = resample(tsin,timevec,interpmethod,code)

Description

example

tsout = resample(tsin,timevec) resamples a timeseries object tsin using a new time vector timevec. The resample function uses the interpolation method associated with tsin, which you can display using the command getinterpmethod(tsin).

tsout = resample(tsin,timevec,interpmethod) resamples tsin using a specified interpolation method. interpmethod can be 'linear' for linear interpolation or 'zoh' for zero-order hold.

tsout = resample(tsin,timevec,interpmethod,code) applies the quality codes in code to all samples.

Examples

collapse all

Create a timeseries object, and resample it using linear interpolation according to the times in timevec. Compare the original data to the resampled data.

tsin = timeseries([1.1 2.9 3.7 4.0 3.0]',1:5);
tsout = resample(tsin,[1 1.5 3.5 4.5 4.9]);
tsindata = tsin.Data
tsindata = 5×1

    1.1000
    2.9000
    3.7000
    4.0000
    3.0000

tsoutdata = tsout.Data
tsoutdata = 5×1

    1.1000
    2.0000
    3.8500
    3.5000
    3.1000

Input Arguments

collapse all

Input timeseries, specified as a scalar.

New time vector, specified as a vector of times for resampling.

When the original time vector contains dates and times but timevec is numeric, resample defines timevec relative to the tsin.TimeInfo.StartDate property using the existing units.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Interpolation method, specified as one of the following options:

  • 'linear' — Linear interpolation

  • 'zoh' — Zero-order hold

Quality codes, specified as [] or a scalar, vector, or multidimensional array of integers ranging from -128 to 127.

  • When the quality code value is a vector, it must have the same length as the time vector. Each element applies to the corresponding data sample.

  • When the quality code value is an array, it must have the same size as the data array. Each element applies to the corresponding data element of the data array.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Introduced before R2006a

Was this topic helpful?