Reputation: 1269
I have an array of, say, end of month datenum
in Matlab. I am looking for a function to check if the dates are consecutive. Consider the following array of dates:
Dates = [datenum(2000,1:10,eomday(2000,1:10)),datenum(2000,12,31),datenum(2001,1:2,eomday(2001,1:2))];
datestr(Dates)
ans =
31-Jan-2000
29-Feb-2000
31-Mar-2000
30-Apr-2000
31-May-2000
30-Jun-2000
31-Jul-2000
31-Aug-2000
30-Sep-2000
31-Oct-2000
31-Dec-2000
31-Jan-2001
28-Feb-2001
where the 30-Nov-2000 is missing. I would like a functionality to identify that 31-Jan-2000 to 31-Oct-2000 are consecutive, that 30-Nov-2000 is missing, and that 31-Dec-2000 to 28-Feb-2001 are consecutive.
Any ideas??
Upvotes: 0
Views: 262
Reputation: 1635
You can convert your dates to serial numbers using datenum
, then you can do a diff
on it and find
values greater than the datenum of your desired interval.
Upvotes: 2