Detect a jump in datetime - series

10 vues (au cours des 30 derniers jours)
Jeroen Vermond
Jeroen Vermond le 14 Août 2018
Commenté : Jeroen Vermond le 14 Août 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?

Réponse acceptée

Adam Danz
Adam Danz le 14 Août 2018
This just happened to me the other day.
Capitalize your 'hh'. It should be
= datetime(t,'InputFormat','dd.MM.yyyy HH:mm:ss');
  1 commentaire
Jeroen Vermond
Jeroen Vermond le 14 Août 2018
Indeed! Thank you very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Calendar dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by