Creating timeseries using date num
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Poulomi Ganguli
le 5 Août 2017
Commenté : Star Strider
le 5 Août 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 commentaires
Réponse acceptée
Star Strider
le 5 Août 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 commentaire
Star Strider
le 5 Août 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Time Series Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!