Detect a jump in datetime - series

7 次查看(过去 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?

采纳的回答

Adam Danz
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 CenterFile Exchange 中查找有关 Dates and Time 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by