synchronize
使用公共时间向量同步两个 timeseries
对象并重采样
说明
注意
此 synchronize
函数应用于使用 timeseries
函数创建的对象。有关同步 timetable
(不推荐同步 timeseries
)的信息,请参阅 synchronize
。
[
使用公共时间向量和指定的方法,通过同步 ts1
,ts2
] = synchronize(ts1
,ts2
,synchronizemethod
)ts1
和 ts2
创建两个新的 timeseries
对象。
[
在上述语法的基础上,指定 ts1
,ts2
] = synchronize(___,Name,Value
)Name,Value
对组参量形式的一个或多个额外选项来创建两个新 timeseries
对象。
示例
同步 timeseries
对象
创建两个 timeseries
对象,使 ts1.timeinfo.StartDate
比 ts2.timeinfo.StartDate
晚一天。
ts1 = timeseries([1 2],[datestr(now); datestr(now+1)]); ts2 = timeseries([1 2],[datestr(now-1); datestr(now)]);
将 ts1.timeinfo.StartDate
更改为匹配 ts2.timeinfo.StartDate
并将 ts1.Time
更改为 1。
[ts1 ts2] = synchronize(ts1,ts2,'union');
以下命令保留 ts1.timeinfo.StartDate
并使 ts1.Time
保持为 0。
[ts1 ts2] = synchronize(ts1,ts2,'union','KeepOriginalTimes',true);
输入参数
ts1
— 第一个输入 timeseries
标量
第一个输入 timeseries
,指定为标量。
数据类型: timeseries
ts2
— 第二个输入 timeseries
标量
第二个输入 timeseries
,指定为标量。
数据类型: timeseries
synchronizemethod
— 同步方法
'Union'
| 'Intersection'
| 'Uniform'
同步方法,指定为以下选项之一:
'Union'
- 使用属于ts1
和ts2
的时间向量并集的时间向量在两个时间向量重叠的时间范围内对timeseries
对象重采样。'Intersection'
- 根据属于ts1
和ts2
的时间向量交集的时间向量对timeseries
对象重采样。'Uniform'
- 需要如下所示的其他参量:[ts1,ts2] = synchronize(ts1,ts2,'Uniform','Interval',value)
该方法根据均匀时间向量对时间序列重采样,其中
value
指定两个连续样本之间的时间间隔。均匀时间向量是ts1
和ts2
的时间向量的重叠部分。间隔单位是ts1
和ts2
的较小单位。
名称-值参数
将可选的参量对组指定为 Name1=Value1,...,NameN=ValueN
,其中 Name
是参量名称,Value
是对应的值。名称-值参量必须出现在其他参量之后,但参量对组的顺序无关紧要。
在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name
引起来。
示例: [ts1,ts2] = synchronize(ts1,ts2,'tolerance',1e-13)
InterpMethod
— 插值方法
'linear'
(默认) | 'zoh'
用于同步操作的插值方法,如使用线性插值则指定为 'linear'
,如使用零阶保持则指定为 'zoh'
。插值方法也可以指定为包含用户定义的插值方法的 tsdata.interpolation
对象。
QualityCode
— 质量代码
[]
(默认) | 标量 | 向量 | 多维数组
质量代码,指定为 []
或由从 -128 到 127 的整数构成的标量、向量或多维数组。
当质量代码为向量时,它的长度必须与时间向量相同。每个元素应用于对应的数据样本。
当质量代码值为数组时,它的大小必须与数据数组相同。每个元素应用于数据数组的对应数据元素。
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
KeepOriginalTimes
— 原始时间指示符
true
| false
原始时间向量,指定为 true
以保留原始时间值,或指定为 false
以使用其他时间值。
数据类型: logical
tolerance
— 容差
1e-10
(默认) | 实数标量
容差,指定为实数值标量,定义用于区分 ts1
和 ts2
两个时间值的容差。例如,ts1
中的第六个时间值是 5+(1e-12)
,而 ts2
中的第六个时间值是 5-(1e-13)
,这两个值默认都视为 5。要区分这两个时间,您可以将 'tolerance'
设置为较小的值,例如 1e-15
。
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
输出参量
ts1
— 第一个输出 timeseries
标量
同步并重采样的第一个输出 timeseries
,指定为标量。
数据类型: timeseries
ts2
— 第二个输出 timeseries
标量
同步并重采样的第二个输出 timeseries
,指定为标量。
数据类型: timeseries
版本历史记录
在 R2006a 之前推出
另请参阅
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)