how to use datetime(datestr)

조회 수: 3 (최근 30일)
zhize lee
zhize lee 2020년 8월 9일
댓글: Walter Roberson 2020년 8월 12일
Dear all, I tried to convert the matlab serial dates (vector) back to a date string . I use matlab2016b. The data and codein the attached file.
And the error is:
Could not recognize the format of the date/time text. You can specify a format character vector using the 'InputFormat' parameter.
If the date/time text contain day, month, or time zone names in a language foreign to the 'zh_CN' locale, those might not be
recognized. You can specify a different locale using the 'Locale' parameter.
Error in test (line 2)
Time = datetime(datestr((DATA(:,1)+datenum('12/31/1899','mm/dd/yy'))));time_num is a vector of serial dates. I have attached the file please.
Thank you very much!

답변 (1개)

Walter Roberson
Walter Roberson 2020년 8월 9일
Do not try to mix serial data numbers and datetime objects.
You can skip most of your problems.
t = readtable('data.xlsx');
Time = t{:,1};
Time will already be in datetime format, having been automatically converted from Excel date format.
  댓글 수: 8
zhize lee
zhize lee 2020년 8월 12일
but, how can just change the code with the original form.Thank you!
Walter Roberson
Walter Roberson 2020년 8월 12일
With the posted code, you can just use what I posted already,
t = readtable('data.xlsx');
Time = t{:,1};
You have not posted any code beyond that, and any code beyond that would have to be using datestr() if it wanted datestr because your current code is already generating datetime objects.
can you give me your email
Sorry, I work with code that is posted in public. I do not read most of the code that is sent to me in email; I either let it sit without response, or else I tell the person that they need to post it in public if they want a response from me (unless they want to hire me.)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by