Converting hhmmss.mmm to hh:mm:ss.mmm, or something like that
Show older comments
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-
Answers (2)
Jan
on 17 May 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
on 17 May 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.
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!