Main Content

resample

Resample tscollection time vector

Description

tscout = resample(tscin,timevec) resamples a tscollection object tscin using a new time vector timevec. The resample function uses the interpolation method associated with each timeseries in tscin.

example

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

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

Examples

collapse all

Resample a tscollection object made up of two timeseries objects.

Create a tscollection object from two timeseries objects.

ts1=timeseries([1.1 2.9 3.7 4.0 3.0]',1:5,'Name','Acceleration');
ts2=timeseries([3.2 4.2 6.2 8.5 1.1]',1:5,'Name','Speed');
tscin = tscollection({ts1,ts2})
Time Series Collection Object: unnamed

Time vector characteristics

      Start time            1 seconds
      End time              5 seconds

Member Time Series Objects:

      Acceleration
      Speed

Resample the data in tscin according to a new time vector using zero-order hold interpolation.

tsout = resample(tscin,[1 1.5 3.5 4.5 4.9],'zoh')
Time Series Collection Object: unnamed

Time vector characteristics

      Start time            1 seconds
      End time              4.900000e+00 seconds

Member Time Series Objects:

      Acceleration
      Speed

Input Arguments

collapse all

Input tscollection, 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 tscin.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