setinterpmethod - Set default interpolation method for timeseries
object - MATLAB ([original](https://in.mathworks.com/help/matlab/ref/timeseries.setinterpmethod.html)) ([raw](?raw))
Main Content
Set default interpolation method for timeseries
object
Syntax
Description
ts = setinterpmethod([ts](#bso32iv-1-ts),[interpmethod](#d126e1517542))
sets the default interpolation method of atimeseries
object.interpmethod
can be'linear'
for linear interpolation or'zoh'
for zero-order hold.
ts = setinterpmethod([ts](#bso32iv-1-ts),[fun](#bso32iv-1-fhandle))
uses a function handle fun
to set the default interpolation method of ts
.
ts = setinterpmethod([ts](#bso32iv-1-ts),[interpobj](#bso32iv-1-interpobj))
uses a tsdata.interpolation
objectinterpobj
to replace the interpolation object stored in ts
.
Examples
Set the interpolation method of a timeseries
object in three ways.
Create a timeseries
object and set the interpolation method to zero-order hold.
ts = timeseries(rand(100,1),1:100); ts = setinterpmethod(ts,'zoh'); plot(ts)
Set the default interpolation method using a function handle.
fun = @(newtime,oldtime,olddata)... interp1(oldtime,olddata,newtime,... 'linear','extrap'); ts = setinterpmethod(ts,fun); plot(ts)
Set the default interpolation method to a tsdata.interpolation
object.
interpobj = tsdata.interpolation(fun); ts = setinterpmethod(ts,interpobj); plot(ts)
Input Arguments
Input timeseries
, specified as a scalar.
Data Types: timeseries
Interpolation method, specified as one of the following options:
'linear'
— Linear interpolation'zoh'
— Zero-order hold
Interpolation method handle, specified as a scalar function handle defining the interpolation method. The order of input arguments for the function handle must be newtime
,oldtime
, andolddata
. A single output argument must contain the interpolated data.
Data Types: function_handle
Interpolation object, specified as atsdata.interpolation
object that directly replaces the interpolation object stored in ts.
Version History
Introduced before R2006a