Creating timeseries using date num

4 次查看(过去 30 天)
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?

采纳的回答

Star Strider
Star Strider 2017-8-5
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 个评论
Star Strider
Star Strider 2017-8-5
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by