How to filter two different datasets based on timestamp using matlab?

78 Views Asked by At

I have two following datasets namely,

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]

And 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]

Now I want to filter the both datasets based on timestamp of 10 min average. For example select the data from both x1 and x2 where they same timestamp. I know we can use 'datenum' to calculate individual ones

I have written code below,

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);

I have calculated the diff between each time stamp but after that I am not able to get an idea on how to use intersect or any other function which will select the data's which is on 10 min resolution and those are not replace those value with zeros. I would be happy if you can help me on this ?

0

There are 0 best solutions below