cell to string to date time
이전 댓글 표시
I am importing a time from a .txt file. The import was auto-generated by matlab. The timestamp array is in this form: '2015-08-07 13:12:00' The variable is a 100x1 cell...I am not sure how to get the cell to a usable date time. Thank you.
...I can also import from the auto-generated import, however the import format does not match any of the available formats.
답변 (2개)
Walter Roberson
2015년 8월 16일
datenum(TheCell)
to return the older serial datenum objects.
datetime(TheCell)
to return the newer datetime objects.
Peter Perkins
2015년 8월 18일
Samantha, it sounds like you have code that you generated using the Import Tool. When you import a text file using the IT, you can specify that a particular column is datetime strings, and even specify a custom format for the strings. I cooked up a file with one column of numbers and one column of datetime strings, and the code I generated contains a line like
formatSpec = '%f%{yyyy-MM-dd HH:mm:ss}D%[^\n\r]';
That script/function will import that column as a datetime array. It's not clear if that's what you're looking to do.
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!