Documentation

setinterpmethod

Class:timeseries

Set default interpolation method fortimeseriesobject

Syntax

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

Description

ts= setinterpmethod(ts,method)sets the default interpolation method,method, fortimeseriesobject,ts, and outputs it tots1.

ts= setinterpmethod(ts,fhandle)sets the default interpolation method fortimeseriesobjectts, wherefhandleis a function handle to the interpolation method.

ts= setinterpmethod(ts,interpobj)sets the default interpolation method fortimeseriesobjectts, whereinterpobjis atsdata.interpolationobject that directly replaces the interpolation object stored ints.

Input Arguments

ts

Thetimeseriesobject for which you want to set the default interpolation method.

method

A string specifying the interpolation method. Valid values arelinearand zero-order hold,zoh.

Default:linear

fhandle

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

interpobj

Atsdata.interpolationobject that directly replaces the interpolation object stored ints.

Output Arguments

ts1

Thetimeseriesobject that results when you set the interpolation method for the originaltimeseriesobject.

Examples

Set the default interpolation method fortimeseriesobjecttsto zero order hold:

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

Set the default interpolation method fortimeseriesobjectts, wherefhandleis a function handle to the interpolation method defined by function handlemyFuncHandle:

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 fortimeseriesobjecttsto atsdata.interpolationobject:

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);

Tips

  • This method is case sensitive.

Introduced before R2006a

Was this topic helpful?