Problem with dates and intersect
Show older comments
Hello everyone,
i came across the following problem this morning and I haven't been able to fix it for the last few hours.. so I am hoping, someone here might be able to help out.
I have two date vectors. One contains all dates for the year 2011:
dat_2011=(datenum(2011,01,01,0,0,0):1/24:datenum(2011,12,31,23,0,0))';
The other one contains only some of the dates of the year 2011: in total it contains 8461 dates of the year 2011. This vector ist called dat_xx
Now I want to use intersect to find out which indexes in vector dat_2011 correspond to the dates in vector dat_xx. So it is very important to me to find out ia and ib:
[dat_xx,ia,ib]=intersect(dat_2011,dat_xx,'rows');
When I run my code, matlab tells me that there are in total only 7722 dates that are the same in the two vectors. ia and ib both have 7722 entries. The problem is, that i know, that in total there should be 8461 dates that are part of both vectors.
Did I maybe do something wrong when I created the vector dat_2011?
I can use several matlab functions like hour, month, year, minute, second for all the elements in both of my date vectors... so I have now idea what the problem could be... matlab seems to recognize the elements in both vectors as dates...
Thanks alot!!
Accepted Answer
More Answers (0)
Categories
Find more on Time Series Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!