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!