How can I convert a time vector of HH:SS to a decimal?
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Newbie
 el 30 de Ag. de 2021
  
    
    
    
    
    Respondida: Steven Lord
    
      
 el 30 de Ag. de 2021
            I have a vector of time in format HH:SS in a table and I want to convert it to a decimal number.
For example:
03:30 = 3.5
04:45 = 4.75
How can I do that?
Thanks.
2 comentarios
Respuesta aceptada
  Steven Lord
    
      
 el 30 de Ag. de 2021
        If you have them stored as a duration array just use the hours function.
du = duration({'03:30', '04:45'}, 'InputFormat', 'hh:mm')
hours(du)
0 comentarios
Más respuestas (1)
  Jan
      
      
 el 30 de Ag. de 2021
        v = datetime({'03:30', '04:45'}, 'InputFormat', 'HH:mm')
hour(v) + minute(v) / 60
0 comentarios
Ver también
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!