Problem in creating hourtly timestamp (time axe)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello I am tring to create a time axis (time vetor) with the following command:
num_date1 = datenum (03/05/2003 00: 00: 00, 'dd / mm / yyyy HH: MM: SS')
num_dateend = datenum (01/01/2018 00: 00: 00, 'dd / mm / yyyy HH: MM: SS')
Mod = datenum ('01 / 01/2000 01:00:00 ',' dd / mm / yyyy HH: MM: SS ') - datenum ('01 / 01/2000 00:00:00', 'dd / mm / yyyy HH: MM: SS ') %Mod=0.041666666627861559391021728515625; %Horaire
num_dateOK = num_date1: Mod: num_dateend
when I display the result (datestr (num_dateOK, 'dd / mm / yyyy HH: MM: SS')) I find that in a certain moment matlab crash, and it give me a not correct axis of time in the following form:
31/12/2017 09:59:59 12/31/2017 10:59:59 31/12/2017 11:59:59 12/31/2017 12:59:59 31/12/2017 13:59:59 31/12/2017 14:59:59 31/12/2017 15:59:59 31/12/2017 16:59:59 31/12/2017 17:59:59 12/31/2017 18:59:59 12/31/2017 7:59:59 31/12/2017 20:59:59 12/31/2017 9:59:59 12/31/2017 22:59:59 31/12/2017 23:59:59
can someone help me please?
0 Kommentare
Antworten (1)
jonas
am 25 Sep. 2018
Bearbeitet: jonas
am 25 Sep. 2018
First of all, your code is buggy. There is no way you can execute those lines by copying them to the workspace, so it is impossible to find your error(s).
More importantly, do not use the outdated format where dates are described by doubles. Use datetime instead.
num_date1 = datetime(2003,05,03,00,00,00)
num_dateend = datetime(2018,01,01,00,00,00)
num_dateOK = num_date1:hours(1):num_dateend
Just change the interval (currently set to 1 hour) per your desire.
Note. Would you rather use a string as input when specifying the date, this is not an issue
num_date1 = datetime('03/05/2003 00:00:00','inputformat','dd/MM/yyyy hh:mm:ss')
2 Kommentare
jonas
am 25 Sep. 2018
Happy to help! You should still consider using datetime. You are very unlikely to ever go back to datevec if you try ;)
Siehe auch
Kategorien
Mehr zu Dates and Time 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!