Skip to Main Content Skip to Search
Product Documentation

setinterpmethod - Class: timeseries

Set default interpolation method for timeseries object

Syntax

ts = setinterpmethod(ts, method)
ts = setinterpmethod(ts, fhandle)
ts = setinterpmethod(ts, interpobj)

Description

ts = setinterpmethod(ts, method) sets the default interpolation method, method, for timeseries object, ts, and outputs it to ts1.

ts = setinterpmethod(ts, fhandle) sets the default interpolation method for timeseries object ts, where fhandle is a function handle to the interpolation method.

ts = setinterpmethod(ts, interpobj) sets the default interpolation method for timeseries object ts, where interpobj is a tsdata.interpolation object that directly replaces the interpolation object stored in ts.

Tips

Input Arguments

ts

The timeseries object for which you want to set the default interpolation method.

method

A string specifying the interpolation method. Valid values are linear and zero-order hold, zoh.

Default: linear

fhandle

A function handle to the interpolation method. The order of input arguments defining the function handle must be new_time, time, and data. The single output argument must be the interpolated data only.

interpobj

A tsdata.interpolation object a tsdata.interpolation object that directly replaces the interpolation object stored in ts.

Output Arguments

ts1

The timeseries object that results when you set the interpolation method for the original timeseries object.

Examples

Set the default interpolation method for timeseries object ts to zero order hold:

ts = timeseries(rand(100,1),1:100);
ts = setinterpmethod(ts,'zoh');
plot(ts);

Set the default interpolation method for timeseries object ts, where fhandle is a function handle to the interpolation method defined by function handle myFuncHandle:

ts = timeseries(rand(100,1),1:100);
myFuncHandle = @(new_time, time, data)...
               interp1(time, data, new_time,...
                       'linear','extrap');
ts = setinterpmethod(ts, myFuncHandle);
ts = resample(ts, [-5:0.1:10]);
plot(ts);

Set the default interpolation method for timeseries object ts to a tsdata.interpolation object:

ts = timeseries(rand(100,1),1:100);
myFuncHandle = @(new_time, time, data)...
               interp1(time, data, new_time,...
                       'linear','extrap');
myInterpObj = tsdata.interpolation(myFuncHandle);
ts = setinterpmethod(ts,myInterpObj);
plot(ts);

See Also

getinterpmethod | timeseries

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS