如何使用matlab基于时间戳过滤两个不同的数据集?

时间:2016-12-22 11:47:47

标签: matlab sorting time timestamp intersection

我有两个以下数据集,即

datasets1,

t2 ={'2012-08-01 22:20:00.0'
        '2012-08-01 22:30:00.0'
        '2012-08-01 22:40:00.0'
        '2012-08-01 22:50:00.0'
        '2012-08-01 23:00:00.0'
        '2012-08-01 23:10:00.0'
        '2012-08-01 23:20:00.0'
        '2012-08-01 23:30:00.0'
        '2012-08-01 23:40:00.0'
        '2012-08-01 23:50:00.0'
        '2012-08-02 00:00:00.0'
        '2012-08-02 00:10:00.0'
        '2012-08-02 00:20:00.0'
        '2012-08-02 00:30:00.0'
        '2012-08-02 00:40:00.0'
        '2012-08-02 00:50:00.0'
        '2012-08-02 19:20:00.0'
        '2012-08-02 19:30:00.0'
        '2012-08-02 19:40:00.0'
        '2012-08-02 19:50:00.0'
        '2012-08-02 20:00:00.0'}

x1 = [11.511 
      11.378
      11.231
      10.951
      10.891
      10.796
      10.757
      10.644
      10.514
      10.519
      10.513
      10.468
      10.658 
      10.562
      10.659
      10.646
      14.216
      13.976
      13.623
      13.537
      13.410]

和datasets2,

t2 ={'2012-08-01 22:20:00.0'
     '2012-08-01 22:30:00.0'
     '2012-08-01 22:40:00.0'
     '2012-08-01 22:50:00.0'
     '2012-08-01 23:00:00.0'
     '2012-08-01 23:10:00.0'
     '2012-08-01 23:20:00.0'
     '2012-08-01 23:30:00.0'
     '2012-08-01 23:40:00.0'
     '2012-08-01 23:50:00.0'
     '2012-08-02 00:00:00.0'
     '2012-08-02 00:10:00.0'
     '2012-08-02 00:20:00.0'
     '2012-08-02 00:30:00.0'
     '2012-08-02 00:40:00.0'
     '2012-08-02 00:50:00.0'
     '2012-08-02 01:00:00.0'
     '2012-08-02 01:10:00.0'
     '2012-08-02 01:20:00.0'
     '2012-08-02 01:30:00.0'
     '2012-08-02 01:40:00.0'}

y = [94.743
     15.119
     28.776
     109.958
     81.391
     38.437
     68.402
     67.012
     55.645
     39.614
     38.699 
     9.0157
    -10.412
    -27.198
    -34.110
    -31.812
    -31.292
    -27.861
    -33.740
    -32.629
    -31.958]

现在我想根据平均10分钟的时间戳过滤这两个数据集。例如,从x1和x2中选择相同时间戳的数据。我知道我们可以使用' datenum'计算个别

我在下面写了代码,

formatIn = 'yyyy-mm-dd HH:MM:SS'; b = datenum(t1,formatIn); format long diffs = diff(b);

formatIn = 'yyyy-mm-dd HH:MM:SS';
d = datenum(t2,formatIn);
format long
dif = diff(d);

我已经计算了每个时间戳之间的差异,但之后我无法知道如何使用交叉或任何其他功能来选择10分钟分辨率的数据,这些是不要用零替换这些值。如果你可以帮助我,我会很高兴吗?

0 个答案:

没有答案