Documentation Center

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

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

  • This method is case sensitive.

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

|

Was this topic helpful?