Detect a jump in datetime - series
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi!
I have imported a table, including timestamp values. The string array, called t, has dimensions 8602x1. Around an index of 8000 there is a jump in time, see the following close up of the array:
"10.08.2018 11:37:08"
"10.08.2018 11:37:09"
"10.08.2018 11:37:10"
"10.08.2018 11:37:11"
"10.08.2018 11:37:14"
"10.08.2018 11:37:15"
"10.08.2018 12:12:01"
"10.08.2018 12:12:02"
"10.08.2018 12:12:03"
"10.08.2018 12:12:04"
I was looking in to the datetime function and I thought this could be useful to calculate the time difference between adjacent values. So I did the following:
t2 = datetime(t,'InputFormat','dd.MM.yyyy hh:mm:ss');
dt = diff(t2);
This works fine, except when time becomes larger than 12:00:00, in that case dt becomes negative. For the following values dt becomes -11:25:14:
"10.08.2018 11:37:15"
"10.08.2018 12:12:01"
I was wondering how to configure my script so it takes into account the 24h of a day. The final goal is to know at which index of the series a jump in time larger than for example 3s occurs. In my imported data a day starts (in this case 10:08:2018) at midnight, 00:00:00. Maybe someone knows how to achieve my goal?
댓글 수: 0
채택된 답변
Adam Danz
2018년 8월 14일
This just happened to me the other day.
Capitalize your 'hh'. It should be
= datetime(t,'InputFormat','dd.MM.yyyy HH:mm:ss');
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!