Converting hhmmss.mmm to hh:mm:ss.mmm, or something like that
Afficher commentaires plus anciens
My array includes a column of time data which is in the format "hhmmss.mmm".
An example is "155313.894", which means 15:53:13.894 (hh:mm:ss.mmm).
I would like to convert this value into a time value that I can use to plot in either Matlab or Excel.
datestr($$$) does not work because there is no date data, only time.
Suggestions? Help?
Thanks!
-adam-
Réponses (2)
Jan
le 17 Mai 2011
Str = '155313.894';
Converted1 = sprintf('%c%c:%c%c:%s', Str)
Or:
Converted2 = [Str(1:2), ':', Str(3:4), ':', Str(5:10)]
Matt Fig
le 17 Mai 2011
It is not clear to me whether you want a number or another string in a different format. If you want a number, stop after the first line below:
N = datenum('155313.894','HHMMSS.FFF')
S = datestr(N,13) % Pick which format you like. See DATESTR help.
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!