Converting Given times to a Vector
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
I have a series of 4158 time points that i must convert from the hh:mm:ss.ss format to something i can use in matlab. this set of data is contained in cells in excel.
0 件のコメント
回答 (2 件)
Star Strider
2016 年 3 月 25 日
Without having your file it’s difficult to write specific code. However:
time_cell = {'12:34:56.01'; '12:34:57.50'}; % Create Data
dn = datenum(time_cell, 'HH:MM:SS.FFF'); % Convert To Date Numbers
Check = datevec(dn) % Check Conversion (Delete)
will work if I made the correct assumptions about it.
2 件のコメント
marco hosfeld
2016 年 3 月 25 日
Star Strider
2016 年 3 月 25 日
My pleasure.
You said your times were a cell array of strings, that is likely correct if you used the xlsread function to import your data. They don’t have to look exactly the same as the cell array I used to test my code.
Did you test your data with my code example?
Did it work?
If not, what was the error?
Steven Lord
2016 年 3 月 25 日
Rather than using serial date numbers as Star Strider suggested, if you're using a release where it is available (release R2014b or later) I recommend using datetime with the 'InputFormat' option to specify the format of the dates in the cellstr.
time_cell = {'12:34:56.01'; '12:34:57.50'};
timeFormat = 'hh:mm:ss.SS';
dateVector = datetime(time_cell, 'InputFormat', timeFormat);
dateVector.Format = timeFormat
The last line changes the format used to display the date vector to match the format as it was imported so that the display of the dateVector should match exactly what you see in time_cell.
0 件のコメント
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!