Effacer les filtres
Effacer les filtres

Display elapsed time in hours, minutes, and seconds

39 vues (au cours des 30 derniers jours)
Kim Bostroem
Kim Bostroem le 19 Avr 2023
Commenté : chicken vector le 19 Avr 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?

Réponse acceptée

chicken vector
chicken vector le 19 Avr 2023
time = seconds(4321)
time.Format = 'hh:mm:ss'
  6 commentaires
Kim Bostroem
Kim Bostroem le 19 Avr 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 le 19 Avr 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by