行下标 Matlab,时间表行下标的时间容差

创建包含温度和压力数据且行时间以小时为单位的时间表。行时间中会有轻微的随机变化。选择行时间与时间矢量中的对应时间相匹配的行,容差范围为五秒。

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 =

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 =

1×6 datetime array

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 =

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值