Creating timeseries using date num
2 views (last 30 days)
Show older comments
Poulomi Ganguli
on 5 Aug 2017
Commented: Star Strider
on 5 Aug 2017
I want to create a time series of daily values, in which daily values are reported at 12times/day. Hence the series altogether should have a 4380 values. I tried this way in a first attempt:
data=datenum(2007,1,1,0,0,[0:2:24-1].'):datenum(2007,12,31,0,0,[0:2:24-1].');
However, the result is only 365 values. Any help?
0 Comments
Accepted Answer
Star Strider
on 5 Aug 2017
The datenum function returns days and fractions of days.
Try this:
data = datenum(2007,1,1,0,0,0) : 1/12 : datenum(2007,12,31,23,59,59);
Check = datevec([data(1:3)'; data(end-2:end)']) % Check Results
Check =
2007 1 1 0 0 0
2007 1 1 2 0 0
2007 1 1 4 0 0
2007 12 31 18 0 0
2007 12 31 20 0 0
2007 12 31 22 0 0
1 Comment
Star Strider
on 5 Aug 2017
My code produces the result you want. The times are every 2 hours.
So for January 1st and 2nd:
Jan_1_2 = datevec(data(1:24)')
Jan_1_2 =
2007 1 1 0 0 0
2007 1 1 2 0 0
2007 1 1 4 0 0
2007 1 1 6 0 0
2007 1 1 8 0 0
2007 1 1 10 0 0
2007 1 1 12 0 0
2007 1 1 14 0 0
2007 1 1 16 0 0
2007 1 1 18 0 0
2007 1 1 20 0 0
2007 1 1 22 0 0
2007 1 2 0 0 0
2007 1 2 2 0 0
2007 1 2 4 0 0
2007 1 2 6 0 0
2007 1 2 8 0 0
2007 1 2 10 0 0
2007 1 2 12 0 0
2007 1 2 14 0 0
2007 1 2 16 0 0
2007 1 2 18 0 0
2007 1 2 20 0 0
2007 1 2 22 0 0
More Answers (0)
See Also
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!