Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

resample (tscollection)

Select or interpolate data in tscollection using new time vector

Syntax

tsc = resample(tsc,Time)
tsc = resample(tsc,Time,interp_method)
tsc = resample(tsc,Time,interp_method,code)

Description

tsc = resample(tsc,Time) resamples the tscollection object tsc on the new Time vector. When tsc uses date strings and Time is numeric, Time is treated as numerical specified relative to the tsc.TimeInfo.StartDate property and in the same units that tsc uses. The resample method uses the default interpolation method for each time series member.

tsc = resample(tsc,Time,interp_method) resamples the tscollection object tsc using the interpolation method given by the string interp_method. Valid interpolation methods include 'linear' and 'zoh' (zero-order hold).

tsc = resample(tsc,Time,interp_method,code) resamples the tscollection object tsc using the interpolation method given by the string interp_method. The integer code is a user-defined quality code for resampling, applied to all samples.

Examples

The following example shows how to resample a tscollection that consists of two timeseries members.

  1. Create 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');
    
  2. Create a tscollection tsc.

    tsc=tscollection({ts1 ts2});
    

    The time vector of the collection tsc is [1:5], which is the same as for ts1 and ts2 (individually).

  3. Get the interpolation method for acceleration by typing

    tsc.acceleration
    
    

    MATLAB® responds with

    Time Series Object: acceleration
    
    Time vector characteristics
    
          Length                5
          Start time            1 seconds
          End time              5 seconds
    
    Data characteristics
    
          Interpolation method  linear
          Size                  [1  1  5]
          Data type             double
    
  4. Set the interpolation method for speed to zero-order hold by typing

    setinterpmethod(tsc.speed,'zoh')
    

    MATLAB responds with

    Time Series Object: acceleration
    
    Time vector characteristics
    
          Length                5
          Start time            1 seconds
          End time              5 seconds
    
    Data characteristics
    
          Interpolation method  zoh
          Size                  [1  1  5]
          Data type             double
    
  5. Resample the time-series collection tsc by individually resampling each time-series member of the collection and using its interpolation method.

    res_tsc=resample(tsc,[1 1.5 3.5 4.5 4.9])
    

See Also

| |

Was this topic helpful?