Problem with formatting time

I have a column of times in the format:
HH:MM:SS.FFF
(so seconds are to 3 decimal places). I'm trying to import this column but I can't find a way to format it properly. I've tried custom formatting, namely:
HH:MM:SSSSSS HH:MM:SSSSS HH:MM:SS.SSS
but am being returned "NaN", and:
HH:MM:SS.FFF
but I'm getting an exponential number instead. I'd really like to get it in the hour-min-sec format. What should I do?

Antworten (1)

Jan
Jan am 21 Feb. 2017
Bearbeitet: Jan am 21 Feb. 2017

0 Stimmen

Please post exactly what you do: What is the input source? A file, a cell string, a string? With which function or tool do you want to import the values?
The "exponential number" you get is the serial date format. You can simply convert it by datevec or datestr depending on what "hour-min-sec format" exactly mean.
It might be cheaper to treat the date string as a string and import it as numerical values directly by:
%d:%d:%f

Diese Frage ist geschlossen.

Gefragt:

am 21 Feb. 2017

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by