withtol
时间表行下标的时间容差
说明
示例
指定用于匹配行时间的容差
创建包含温度和压力数据且行时间以小时为单位的时间表。行时间中会有轻微的随机变化。选择行时间与时间向量中的对应时间相匹配的行,容差范围为五秒。
Time = datetime(2015,12,18) + hours(1:10)' + seconds(randn(10,1)); Temp = [37.3 39.1 42.3 42.6 43 43.9 44.1 43.3 42.5 42]'; Pressure = [29.4 29.6 30.0 30.0 30.1 29.9 29.9 29.8 29.6 29.7]'; TT = timetable(Time,Temp,Pressure)
TT=10×2 timetable
Time Temp Pressure
____________________ ____ ________
18-Dec-2015 01:00:00 37.3 29.4
18-Dec-2015 02:00:01 39.1 29.6
18-Dec-2015 02:59:57 42.3 30
18-Dec-2015 04:00:00 42.6 30
18-Dec-2015 05:00:00 43 30.1
18-Dec-2015 05:59:58 43.9 29.9
18-Dec-2015 06:59:59 44.1 29.9
18-Dec-2015 08:00:00 43.3 29.8
18-Dec-2015 09:00:03 42.5 29.6
18-Dec-2015 10:00:02 42 29.7
创建时间跨度从 3:00 到 8:00 的时间向量。
newTimes = datetime(2015,12,18) + hours(3:8)
newTimes = 1x6 datetime
Columns 1 through 3
18-Dec-2015 03:00:00 18-Dec-2015 04:00:00 18-Dec-2015 05:00:00
Columns 4 through 6
18-Dec-2015 06:00:00 18-Dec-2015 07:00:00 18-Dec-2015 08:00:00
选择 TT
中行时间与 newTimes
中的时间相匹配的行,容差范围为五秒。
S = withtol(newTimes,seconds(5)); TT2 = TT(S,:)
TT2=6×2 timetable
Time Temp Pressure
____________________ ____ ________
18-Dec-2015 02:59:57 42.3 30
18-Dec-2015 04:00:00 42.6 30
18-Dec-2015 05:00:00 43 30.1
18-Dec-2015 05:59:58 43.9 29.9
18-Dec-2015 06:59:59 44.1 29.9
18-Dec-2015 08:00:00 43.3 29.8
输入参数
rowTimes
— 要在时间表中匹配的时间
日期时间数组 | 持续时间数组 | 字符向量元胞数组 | 字符串数组
要在时间表中匹配的时间,指定为日期时间数组、持续时间数组、字符向量元胞数组或字符串数组。rowTimes
包含的时间不完全匹配时间表的行时间中的时间,但可能在指定的容差范围内。
如果 rowTimes
是字符向量元胞数组或字符串数组,则数组的元素指定 datetime
或 duration
函数可以转换的日期和时间。
tol
— 用于将时间与时间表的行时间进行匹配的容差
持续时间 | 字符向量 | 字符串标量
用于将时间与时间表的行时间进行匹配的容差,指定为持续时间、字符向量或字符串标量。
如果 tol
是字符向量或字符串标量,则 tol
指定 duration
函数可以转换的时间。
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
版本历史记录
在 R2016b 中推出
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)