| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
ts = resample(ts,Time)
ts = resample(ts,Time,interp_method)
ts = resample(ts,Time,interp_method,code)
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.
The following example shows how to resample a timeseries object.
ts=timeseries([1.1 2.9 3.7 4.0 3.0],1:5,'Name','speed');
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.
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
getinterpmethod, setinterpmethod, synchronize, timeseries
![]() | repmat | resample (tscollection) | ![]() |

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 |