Does anyone know to convert clock time into decimal time?

3 visualizaciones (últimos 30 días)
Miguel Kulisic
Miguel Kulisic el 8 de Sept. de 2016
Respondida: George el 8 de Sept. de 2016
Exampler of the data 845 is 8:45 and I want it 875 ( decimal time).

Respuestas (2)

Star Strider
Star Strider el 8 de Sept. de 2016
See if this does what you want:
t_d = @(t) (fix(t/100) + rem(t,100)/60)*100; % Anonymous Function
t_hm = 845; % Time To Be ‘Converted’
out = t_d(t_hm) % Desired Result
out =
875

George
George el 8 de Sept. de 2016
  1. Use num2str
  2. Lop off the last two characters with a(end-1:end)
  3. str2num that
  4. Divide by 60 (e.g., 45/60)
  5. num2str that.
  6. Put that back with the first part of the string from #2 above e.g., a = [a(1:end-1) results from #5]
There's probably a cleaner way to do this. But this should work.

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