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
Walter Roberson 2015년 8월 16일

1 개 추천

datenum(TheCell)
to return the older serial datenum objects.
datetime(TheCell)
to return the newer datetime objects.
Peter Perkins
Peter Perkins 2015년 8월 18일

0 개 추천

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에 대해 자세히 알아보기

질문:

2015년 8월 16일

답변:

2015년 8월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by