Creating a vector of datetimes with increments of 15 minutes
40 次查看(过去 30 天)
显示 更早的评论
Hi all, currently trying to create a datetime vector with the form of 'yyyy-mm-dd HH:mm:ss' ranging from 2020-06-30 23:45:00 to 2015-01-01 00:00:00
in other words, elements should read as follows:
element 1 = 2020-06-30 23:45:00
element 2 = 2020-06-30 23:30:00
and so on.
I've tried converting to datenum for serial numbers and thought I could figure out the increment for 15 minutes and build from the first serialized number to the last such that timevec = t1:step:t_final with step = datenum(t1-t2) type of logic... didn't work out in my favor though.
Any suggestions?
0 个评论
采纳的回答
Star Strider
2020-8-7
Try this:
Timestamp = (datetime('2020-06-30 23:45:00') : -minutes(15) : datetime('2015-01-01 00:00:00')).';
Timestamp.Format = 'yyyy-MM-dd HH:mm:ss';
producing:
First5_Last5 = [Timestamp(1:5); Timestamp(end-4:end)]
First5_Last5 =
10×1 datetime array
2020-06-30 23:45:00
2020-06-30 23:30:00
2020-06-30 23:15:00
2020-06-30 23:00:00
2020-06-30 22:45:00
2015-01-01 01:00:00
2015-01-01 00:45:00
2015-01-01 00:30:00
2015-01-01 00:15:00
2015-01-01 00:00:00
.
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!