Creating timeseries using date num

조회 수: 2 (최근 30일)
Poulomi Ganguli
Poulomi Ganguli 2017년 8월 5일
댓글: Star Strider 2017년 8월 5일
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에서 Time Series Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by