How to measure elapsed time in hh:mm:ss?

37 visualizaciones (últimos 30 días)
JarryG
JarryG el 30 de En. de 2023
Editada: Stephen23 el 30 de En. de 2023
Hi,
till now I measured elapsed time with:
tic;
% some code here
datestr(toc/86400,'HH:MM:SS')
Matlab R2022b says "datestr" is not recommended anymore. So how can I now convert timer-value (in seconds) to "hours-minutes-seconds"?

Respuestas (2)

Stephen23
Stephen23 el 30 de En. de 2023
Editada: Stephen23 el 30 de En. de 2023
You can do this with SECONDS(), but then it requires two lines. Here is a simple solution on one line:
tic
..
dur = duration(0,0,toc)

Kunal Kandhari
Kunal Kandhari el 30 de En. de 2023
Hi you can use of seconds function:
tic;
s = seconds(toc/86400);
s.Format = 'hh:mm:ss'
Hope this helps!
  1 comentario
Stephen23
Stephen23 el 30 de En. de 2023
The output of TOC is already in seconds... so dividing by the number of seconds in one day is not useful here.

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by