Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检索特定时间数据旁边的matlab时间表点_Matlab_Search_Timetable - Fatal编程技术网

检索特定时间数据旁边的matlab时间表点

检索特定时间数据旁边的matlab时间表点,matlab,search,timetable,Matlab,Search,Timetable,我在Matlab中有以下时间表: intersectionPoints = 10×1 timetable Timestamp Value ____________________ ______ 01-Feb-2016 00:00:00 1.0848 01-Feb-2016 01:00:00 1.0847 01-Feb-2016 04:00:00 1.0848 02-Feb-2016 1

我在Matlab中有以下
时间表

intersectionPoints =

  10×1 timetable

         Timestamp          Value 
    ____________________    ______

    01-Feb-2016 00:00:00    1.0848
    01-Feb-2016 01:00:00    1.0847
    01-Feb-2016 04:00:00    1.0848
    02-Feb-2016 14:07:44    1.0914
    02-Feb-2016 17:21:36    1.0916
    03-Feb-2016 01:49:18    1.0917
    03-Feb-2016 07:18:43    1.0919
    04-Feb-2016 00:53:20    1.1088
    04-Feb-2016 04:18:16    1.1097
    04-Feb-2016 21:38:10    1.1199
我还提供了以下
timedate

checkDate = datetime("03-Feb-2016 01:49:20")

checkDate = 

  datetime

   03-Feb-2016 01:49:20
time = [datetime('yesterday')
        datetime('today')
        datetime('tomorrow')];
checkDate = datetime('now');
Tbl = timetable(time,(1:length(time)).');

idx = find(Tbl.time > checkDate ,1);

res = Tbl(idx-1:idx,:)
我想从
intersectionPoints
中检索上一行和下一行到特定的时间戳。在我的具体案例中,我需要检索两点:

res =

  2×1 timetable

         Timestamp          Value 
    ____________________    ______

    03-Feb-2016 01:49:18    1.0917
    03-Feb-2016 07:18:43    1.0919
res
是一个包含两个元素的
时间表。这些是过去和将来与
检查日期
相关的
交叉点
检查日期
最近的两个点。我可以循环所有时间戳值并手动检查它们,但效率不高(我的时间表很大)。我还可以对这些元素执行手动二进制搜索,但我想知道是否有内置的或更简单的方法来搜索这两个值


我如何才能找到与已定义值相邻的
时间表
值?

MATLAB的酷之处在于,它是为工程师创建的,应该像非信息学预期的那样工作。因此,只需
find
第一个(
find(…,1)
)元素,它比您的
checkDate

checkDate = datetime("03-Feb-2016 01:49:20")

checkDate = 

  datetime

   03-Feb-2016 01:49:20
time = [datetime('yesterday')
        datetime('today')
        datetime('tomorrow')];
checkDate = datetime('now');
Tbl = timetable(time,(1:length(time)).');

idx = find(Tbl.time > checkDate ,1);

res = Tbl(idx-1:idx,:)