Detect a jump in datetime - series

10 visualizaciones (últimos 30 días)
Jeroen Vermond
Jeroen Vermond el 14 de Ag. de 2018
Comentada: Jeroen Vermond el 14 de Ag. de 2018
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?

Respuesta aceptada

Adam Danz
Adam Danz el 14 de Ag. de 2018
This just happened to me the other day.
Capitalize your 'hh'. It should be
= datetime(t,'InputFormat','dd.MM.yyyy HH:mm:ss');

Más respuestas (0)

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by