Borrar filtros
Borrar filtros

Display elapsed time in hours, minutes, and seconds

40 visualizaciones (últimos 30 días)
Kim Bostroem
Kim Bostroem el 19 de Abr. de 2023
Comentada: chicken vector el 19 de Abr. de 2023
Since now datestr is discouraged, I would like to use datetime to display elapsed time in hours, minuts and seconds. My previous code was
datestr(toc, 'HH:MM:SS')
How can I replace this with a command using datetime?

Respuesta aceptada

chicken vector
chicken vector el 19 de Abr. de 2023
time = seconds(4321)
time.Format = 'hh:mm:ss'
  6 comentarios
Kim Bostroem
Kim Bostroem el 19 de Abr. de 2023
I just noticed that one can even print milliseconds using
time = duration(0,0,toc, 'Format', 'hh:mm:ss.SSSS')
chicken vector
chicken vector el 19 de Abr. de 2023
the command seconds is returning an instance of the class duration, that's why you can include the 'Format' command in duration, but not in seconds.

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