Time between two dates
이전 댓글 표시
Lets say I have a time T1 = '2018-03-14 16:30:54' and another T2 = '2018-03-14 16:40:54' How can I find the total duration of the interval, as well as a "midpoint" in between said interval? My goal is to add an NaN entry every time there is a time gap greater than 10 minutes.
For example; '2018-03-14 16:30:54' '2018-03-14 16:40:54' %NaN entry would be added here '2018-03-14 17:20:15' '2018-03-14 17:30:15'
The purpose of adding this entry would be to remove discontinuity in graphs.
채택된 답변
추가 답변 (2개)
Peter Perkins
2018년 4월 19일
>> d = datetime(2018,3,14,16,[30 40],54) d = 1×2 datetime array 14-Mar-2018 16:30:54 14-Mar-2018 16:40:54 >> mean(d) ans = datetime 14-Mar-2018 16:35:54 >> diff(d) ans = duration 00:10:00
How about
T1 = datetime('2018-03-14 16:30:54')
T2 = datetime('2018-03-14 16:40:54')
T_mid = mean([T1, T2])
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!