Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

resample (timeseries) - Select or interpolate timeseries data using new time vector

Syntax

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

Description

ts = resample(ts,Time) resamples the timeseries object ts using the new Time vector. When ts uses date strings and Time is numeric, Time is treated as specified relative to the ts.TimeInfo.StartDate property and in the same units that ts uses. The resample operation uses the default interpolation method, which you can view by using the getinterpmethod(ts) syntax.

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

ts = resample(ts,Time,interp_method,code) resamples the timeseries object ts 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 timeseries object.

  1. Create a timeseries object.

    ts=timeseries([1.1 2.9 3.7 4.0 3.0],1:5,'Name','speed');
    
  2. Transpose ts to make the data columnwise.

    ts=transpose(ts)
    

    The display in the MATLAB Command Window is

    Time Series Object: speed
    
    Time vector characteristics
    
          Length                5
          Start time            1 seconds
          End time              5 seconds
    
    Data characteristics
    
          Interpolation method  linear
          Size                  [5  1]
          Data type             double
    
    Time              Data              Quality
    -------------------------------------------
    1                 1.1
    2                 2.9
    3                 3.7
    4                 4
    5                 3
    

    Note that the interpolation method is set to linear, by default.

  3. Resample ts using its default interpolation method.

    res_ts=resample(ts,[1 1.5 3.5 4.5 4.9])
    
    

    The resampled time series displays as follows:

    Time Series Object: speed
    
    Time vector characteristics
    
          Length                5
          Start time            1 seconds
          End time              4.900000e+000 seconds
    
    Data characteristics
    
          Interpolation method  linear
          Size                  [5  1]
          Data type             double
    
    Time              Data              Quality
    -------------------------------------------
    1                 1.1
    1.5               2
    3.5               3.85
    4.5               3.5
    4.9               3.1
    

See Also

getinterpmethod, setinterpmethod, synchronize, timeseries

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS