How can I convert a double array into a timestamp array?

49 visualizaciones (últimos 30 días)
Guido Pastore
Guido Pastore el 26 de Feb. de 2019
Comentada: Peter Perkins el 11 de Mzo. de 2019
I have an array of double like:
ora: [737426.687937060 737426.687937141 737426.687937176 etc....]
I want to get an array like:
time:[16:30:37:762 16:30:37:769 16:30:37:772]
How can i do??

Respuesta aceptada

Stephan
Stephan el 26 de Feb. de 2019
Editada: Stephan el 26 de Feb. de 2019
Hi,
use:
B = datestr(A, 'HH:MM:SS.FFF')
B =
3×12 char array
'16:30:37.762'
'16:30:37.769'
'16:30:37.772'
to get it as datestring - or (better):
C = datetime(datestr(A, 'HH:MM:SS.FFF'),'InputFormat','HH:mm:ss.SSS','Format','HH:mm:ss.SSS')
C =
3×1 datetime array
16:30:37.762
16:30:37.769
16:30:37.772
to get it as datetime-type.
Best regards
Stephan
  4 comentarios
Guido Pastore
Guido Pastore el 26 de Feb. de 2019
thank you so much!
Peter Perkins
Peter Perkins el 11 de Mzo. de 2019
Alternatively, timeofday(D) would also convert to a duration.

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