Datenum with a.m. and p.m.

14 visualizaciones (últimos 30 días)
Brenton Hirao
Brenton Hirao el 15 de Nov. de 2019
Comentada: Adam Danz el 15 de Nov. de 2019
I have a data set with timestamps:
'11/5/2019 12 a.m. EST'
...
'11/10/2019 1 p.m. EST'
How can I convert these timestamps into a vector of date numbers?
thanks for the help.
  4 comentarios
Adam Danz
Adam Danz el 15 de Nov. de 2019
So you're converting from strings to datenum?
https://www.mathworks.com/help/matlab/ref/datenum.html
It might be necessary to remove the dots first using strrep but maybe not (my machine has been shut down for the night).

Iniciar sesión para comentar.

Respuesta aceptada

Shubham Gupta
Shubham Gupta el 15 de Nov. de 2019
Assuming there is ".m. EST" attached to each "timestamp" at the end. You can follow the steps:
Step-1 Replace ".m. EST" to just "m" (Hint : regexprep)
Step-2 Convert the output into the date numbers (Hint: datenum)
You should get the output with date numbers in a array. (Not sure what do mean by "continuous"?)
  2 comentarios
Adam Danz
Adam Danz el 15 de Nov. de 2019
Instead of the regexprep() you could also do
temp = strrep(S,'.','');

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by