필터 지우기
필터 지우기

Datestr() transforms the matrix of days

조회 수: 2 (최근 30일)
sun
sun 2020년 9월 9일
편집: sun 2020년 9월 9일
I have a matrix with the number of days converted using datenum(). Now I want to convert back to the original date, but the result is wrong.The code is as follows:
day=[737433;737445;737457;737469;737481;737493;737505]
value=datestr(day(1:7),'yyyymmdd');
value=str2num(value);
The execution result is:
value=[101;102;103;104;105;106;107];
actually the results should be
[20190108;20190120;20190201;20190213;20190225;20190309;20190321]
How should I solve this problem? Thank you

답변 (1개)

Star Strider
Star Strider 2020년 9월 9일
I cannot reproduce that. I get what the reults should be (in R2020a):
day=[737433;737445;737457;737469;737481;737493;737505];
value=datestr(day(1:7),'yyyymmdd')
value=str2num(value)
producing:
value =
7×8 char array
'20190108'
'20190120'
'20190201'
'20190213'
'20190225'
'20190309'
'20190321'
and:
value =
20190108
20190120
20190201
20190213
20190225
20190309
20190321
.
  댓글 수: 5
Walter Roberson
Walter Roberson 2020년 9월 9일
At the time that happens, please show us the content of day(1) and also show us
which -all datestr
Star Strider
Star Strider 2020년 9월 9일
Walter — Thank you!

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

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by