Borrar filtros
Borrar filtros

Time of day deduction

4 visualizaciones (últimos 30 días)
Maroulator
Maroulator el 10 de Dic. de 2014
Respondida: Peter Perkins el 11 de Dic. de 2014
I have a matrix with sequential elements from 1 to 86,400; one for every second of the day. Is anyone aware of a built-in function that would allow me to convert any given element value in this array into a figure/string that would show me the corresponding hours, minutes, and seconds (HH:MM:SS)?

Respuesta aceptada

Star Strider
Star Strider el 10 de Dic. de 2014
The datestr function comes quickly to mind.

Más respuestas (1)

Peter Perkins
Peter Perkins el 11 de Dic. de 2014
If you have access to R2014b, the new duration data type will help:
>> d = seconds(0:40:180)
d =
0 secs 40 secs 80 secs 120 secs 160 secs
>> d.Format = 'hh:mm:ss'
d =
00:00:00 00:00:40 00:01:20 00:02:00 00:02:40
>> c = cellstr(d)
c =
'00:00:00' '00:00:40' '00:01:20' '00:02:00' '00:02:40'

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by