setinterpmethod

Sets the interpolation method of a timeseries.

Category: Language Fundamentals > Data Types

Syntax

ts = setinterpmethod(ts, method)

Uses method when the series is evaluated at times that are not samples.

Description

The method is used by resample and by the arithmetic that needs data at common times. Linear interpolation suits continuous signals; zero-order hold suits quantities that stay constant until updated, such as a set point.

Input arguments

ts
A timeseries object.
method
'linear' or 'zoh' (zero-order hold, which repeats the previous value), or an interpolation function handle.

Output arguments

ts
The series with the new method.

Example

ts = timeseries([10 20 30]', [0 1 2]);
ts = setinterpmethod(ts, 'zoh');
r = resample(ts, [0.5 1.5]);
r.Data'
Output
ans = 1×2

    10    20

See also

getinterpmethod resample timeseries interp1