addsample
在 timeseries
对象中添加数据样本
语法
说明
示例
添加数据样本
在一个 timeseries
对象中添加和更改数据。
创建一个 timeseries
对象 ts1
并显示数据和时间样本。
ts1 = timeseries((0:10:50)',(0:5)'); ts1.Data
ans = 6×1
0
10
20
30
40
50
ts1.Time
ans = 6×1
0
1
2
3
4
5
将一个数据样本添加到 ts1
的末尾。
ts2 = addsample(ts1,'Data',60,'Time',6); ts2.Data
ans = 7×1
0
10
20
30
40
50
60
ts2.Time
ans = 7×1
0
1
2
3
4
5
6
将 ts2
中的最后一个数据样本从 60 更改为 100。
ts3 = addsample(ts2,'Data',100,'Time',6,'OverwriteFlag',true); ts3.Data
ans = 7×1
0
10
20
30
40
50
100
输入参数
tsin
— 输入 timeseries
标量
输入 timeseries
,指定为标量。
datavals
— 样本数据
标量 | 向量 | 多维数组
样本数据,指定为数值或 logical
标量、向量或多维数组。
数据类型: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
timevals
— 采样时间
标量 | 向量
采样时间,指定为数值标量或向量,或指定为日期字符向量元胞数组。有效的日期字符向量和字符串可以采用以下格式:
格式 | 示例 |
---|---|
dd-mmm-yyyy HH:MM:SS | 01-Mar-2000 15:45:17 |
dd-mmm-yyyy | 01-Mar-2000 |
mm/dd/yy | 03/01/00 |
mm/dd | 03/01 |
HH:MM:SS | 15:45:17 |
HH:MM:SS PM | 3:45:17 PM |
HH:MM | 15:45 |
HH:MM PM | 3:45 PM |
mmm.dd,yyyy HH:MM:SS | Mar.01,2000 15:45:17 |
mmm.dd,yyyy | Mar.01,2000 |
mm/dd/yyyy | 03/01/2000 |
数据类型: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| cell
s
— 示例结构体
标量
示例结构体,指定为类型为 struct
的标量,并具有以下可选字段:
s.data
- 数据的数值数组s.time
- 数值时间向量,或有效日期字符向量或字符串的元胞数组s.quality
- 从 -128 到 127 的质量代码的整数数组s.overwriteflag
- 覆盖指示符,指定为true
可使用所添加样本覆盖现有数据样本
数据类型: struct
名称-值参数
将可选的参数对组指定为 Name1=Value1,...,NameN=ValueN
,其中 Name
是参数名称,Value
是对应的值。名称-值参数必须出现在其他参数之后,但参数对组的顺序无关紧要。
在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name
引起来。
示例: tsout = addsample(tsin,'Data',5,'Time',3,'OverwriteFlag',true)
Quality
— 质量代码
[]
(默认) | 标量 | 向量 | 多维数组
质量代码,指定为 []
或由从 -128 到 127 的整数构成的标量、向量或多维数组。
当质量代码为向量时,它的长度必须与时间向量相同。每个元素应用于对应的数据样本。
当质量代码值为数组时,它的大小必须与数据数组相同。每个元素应用于数据数组的对应元素。
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
OverwriteFlag
— 覆盖指示符
false
(默认) | true
覆盖指示符,指定为逻辑值,用于控制是否覆盖与所添加样本具有相同关联时间的数据样本。true
指示所添加数据覆盖之前的数据,而 false
会直接添加样本,从而导致重复时间值。
数据类型: logical
版本历史记录
在 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)