I am trying to create a datevec series of dates and times, spaced by 20 minutes, with the minutes column being exactly 0, 20 and 40 with a given starting and ending time. First I create a 20 minute difference value
datenum_20_min_diff = datenum( [ 2021 , 1 , 27 , 17 , 0 ] ) - datenum( [ 2021 , 1 , 27 , 16 , 40 ] ) ;
and then try to create the required datevec series
s = datevec( ( datenum([2021,1,27,22,0]) : datenum_20_min_diff : datenum([2021,1,28,11,0]) )' ) ;
which works for the first few entries but then drifts from what I expect. What I get is (with the minutes column slightly tidied up for ease of viewing)
2.0210e+03 1.0000e+00 2.7000e+01 2.2000e+01 0 0
2.0210e+03 1.0000e+00 2.7000e+01 2.2000e+01 20 0
2.0210e+03 1.0000e+00 2.7000e+01 2.2000e+01 40 0
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 0 0
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 19 6.0000e+01
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 39 6.0000e+01
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 59 6.0000e+01
and what I want/expected is
2.0210e+03 1.0000e+00 2.7000e+01 2.2000e+01 0 0
2.0210e+03 1.0000e+00 2.7000e+01 2.2000e+01 20 0
2.0210e+03 1.0000e+00 2.7000e+01 2.2000e+01 40 0
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 0 0
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 20 0
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 40 0
2.0210e+03 1.0000e+00 2.7000e+01 2.3000e+01 0 0
What am I doing wrong?
question from:
https://stackoverflow.com/questions/65938193/expand-a-datenum-vector 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…