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!