Borrar filtros
Borrar filtros

How to convert decimal to time?

52 visualizaciones (últimos 30 días)
oshawcole
oshawcole el 10 de Oct. de 2017
Editada: Peter Perkins el 13 de Oct. de 2017
eg: 7.6 (7+0.6*60) = 7:36

Respuesta aceptada

per isakson
per isakson el 10 de Oct. de 2017
Editada: per isakson el 10 de Oct. de 2017
datestr takes days as input. Thus, divide by 24.
>> val = 7.6;
>> datestr( val/24, 'HH:MM' )
ans =
07:36
I guessed that seven is hours, not minutes.
  1 comentario
oshawcole
oshawcole el 10 de Oct. de 2017
How do I do it if I want 7:36 PM?

Iniciar sesión para comentar.

Más respuestas (1)

Peter Perkins
Peter Perkins el 13 de Oct. de 2017
Editada: Peter Perkins el 13 de Oct. de 2017
This depends on what you mean by "time". Likely, the most useful thing is a duration:
>> t = hours(7.6)
t =
duration
7.6 hr
>> t.Format = 'hh:mm:ss'
t =
duration
07:36:00

Categorías

Más información sobre Dates and Time 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