timeseries2timetable
说明
TT = timeseries2timetable(
将 ts
)timeseries
数组 ts
转换为时间表。
如果
ts
是timeseries
对象,则TT
是具有一个变量的时间表。如果
ts
是由timeseries
对象组成的数组,则TT
是一个包含的变量数与ts
中的 timeseries 对象数相同的时间表。ts
中的所有timeseries
对象必须具有相同的采样时间。
TT = timeseries2timetable(ts1,...,tsN)
将 timeseries
对象 ts1,...,tsN
转换为一个时间表。TT
中的变量数等于输入数。所有 timeseries
对象 ts1,...,tsN
必须具有相同的采样时间。
示例
将 timeseries
对象转换为时间表
创建一个包含五个随机数的 timeseries
对象,以 10 秒为间隔进行采样。
ts = timeseries(rand(5,1),[0 10 20 30 40])
timeseries Common Properties: Name: 'unnamed' Time: [5x1 double] TimeInfo: tsdata.timemetadata Data: [5x1 double] DataInfo: tsdata.datametadata
显示 ts
中的时间和数据。
ts.Time
ans = 5×1
0
10
20
30
40
ts.Data
ans = 5×1
0.8147
0.9058
0.1270
0.9134
0.6324
将 ts
转换为一个时间表。
TT = timeseries2timetable(ts)
TT=5×1 timetable
Time Data
______ _______
0 sec 0.81472
10 sec 0.90579
20 sec 0.12699
30 sec 0.91338
40 sec 0.63236
来自 timeseries
对象数组的时间表
创建一个 timeseries
对象数组。使用相同的采样时间向量,但为时间序列提供不同的名称。使用 rand
函数创建不同的数据值数组。
ts1 = timeseries(rand(5,1),[0 10 20 30 40],"Name","Series_1"); ts2 = timeseries(rand(5,1),[0 10 20 30 40],"Name","Series_2"); ts3 = timeseries(rand(5,1),[0 10 20 30 40],"Name","Series_3"); ts = [ts1 ts2 ts3]
1x3 timeseries array with properties: Events Name UserData Data DataInfo Time TimeInfo Quality QualityInfo IsTimeFirst TreatNaNasMissing Length
将来自所有 timeseries
对象的数据合并到一个时间表中。数组中的每个时间序列都为该时间表提供一个变量。
TT = timeseries2timetable(ts)
TT=5×3 timetable
Time Series_1 Series_2 Series_3
______ ________ ________ ________
0 sec 0.81472 0.09754 0.15761
10 sec 0.90579 0.2785 0.97059
20 sec 0.12699 0.54688 0.95717
30 sec 0.91338 0.95751 0.48538
40 sec 0.63236 0.96489 0.80028
输入多个时间序列
将多个输入转换为一个时间表。
ts1 = timeseries(rand(5,1),[0 10 20 30 40],"Name","Series_1"); ts2 = timeseries(rand(5,1),[0 10 20 30 40],"Name","Series_2"); ts3 = timeseries(rand(5,1),[0 10 20 30 40],"Name","Series_3"); TT = timeseries2timetable(ts1,ts2,ts3)
TT=5×3 timetable
Time Series_1 Series_2 Series_3
______ ________ ________ ________
0 sec 0.81472 0.09754 0.15761
10 sec 0.90579 0.2785 0.97059
20 sec 0.12699 0.54688 0.95717
30 sec 0.91338 0.95751 0.48538
40 sec 0.63236 0.96489 0.80028
输入参数
ts
— 输入时间序列
timeseries
对象数组
输入时间序列,指定为由 timeseries
对象组成的数组。
此函数使用 ts
的部分属性来分配数据或设置时间表中的属性。对于每个 timeseries
属性,该表描述输出时间表中的结果。
输入 | 输出时间表中的结果 |
---|---|
| 指定对应时间表变量的名称。 如果 |
| 指定分配给对应时间表变量的数据。 |
| 为对应的时间表变量设置 |
| 为对应的时间表变量设置 |
| 将采样时间转换为时间表的行时间。根据输入的 |
| 指定行时间的单位。如果时间表行时间向量是 |
| 设置行时间的格式。 |
| 设置时间表的 |
| 设置 |
| 计算从 |
| 确定数据是否需要重定向。 |
| 将数据赋给时间表的 |
| 警告。 |
| 警告。 |
| 如果 |
版本历史记录
在 R2021b 中推出R2021b: timeseries2timetable
取代了 ts2timetable
timeseries2timetable
函数取代了 ts2timetable
函数,不过 ts2timetable
仍然可用。这两个函数作用相同。在 R2021a 中,MATLAB® 仅提供了 ts2timetable
。
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)