Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

setinterpmethod

设置 timeseries 对象的默认插值方法

说明

示例

ts = setinterpmethod(ts,interpmethod) 设置 timeseries 对象的默认插值方法。如使用线性插值,interpmethod'linear',如使用零阶保持,则为 'zoh'

ts = setinterpmethod(ts,fun) 使用函数句柄 fun 设置 ts 的默认插值方法。

ts = setinterpmethod(ts,interpobj) 使用 tsdata.interpolation 对象 interpobj 替换 ts 中存储的插值对象。

示例

全部折叠

以三种方式设置 timeseries 对象的插值方法。

创建一个 timeseries 对象并将插值方法设置为零阶保持。

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

Figure contains an axes object. The axes object with title Time Series Plot:unnamed, xlabel Time (seconds), ylabel unnamed contains an object of type stair.

使用函数句柄设置默认插值方法。

fun = @(newtime,oldtime,olddata)...
               interp1(oldtime,olddata,newtime,...
                       'linear','extrap');
ts = setinterpmethod(ts,fun);
plot(ts)

Figure contains an axes object. The axes object with title Time Series Plot:unnamed, xlabel Time (seconds), ylabel unnamed contains an object of type line.

将默认插值方法设置为 tsdata.interpolation 对象。

interpobj = tsdata.interpolation(fun);
ts = setinterpmethod(ts,interpobj);
plot(ts)

Figure contains an axes object. The axes object with title Time Series Plot:unnamed, xlabel Time (seconds), ylabel unnamed contains an object of type line.

输入参数

全部折叠

输入 timeseries,指定为标量。

数据类型: timeseries

插值方法,指定为以下选项之一:

  • 'linear' - 线性插值

  • 'zoh' - 零阶保持

插值方法句柄,指定为定义插值方法的标量函数句柄。函数句柄的输入参数的顺序必须是 newtimeoldtimeolddata。单一输出参数必须包含插值数据。

数据类型: function_handle

插值对象,指定为一个 tsdata.interpolation 对象,它直接替换存储在 ts 中的插值对象。

版本历史记录

在 R2006a 之前推出