Creating timeseries using date num
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Poulomi Ganguli
am 5 Aug. 2017
Kommentiert: Star Strider
am 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 Kommentare
Akzeptierte Antwort
Star Strider
am 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 Kommentar
Star Strider
am 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Time Series Objects finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!