이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Convert date from number to format in matllab
조회 수: 3 (최근 30일)
이전 댓글 표시
I have original time and date format as mentioned below:
2/17/2020 9:48:18 AM
I did forecasting using this , and after forecasting output date in the plot appears in number format like :
43878.4085416667
How can i convert it back to original date and time format ?
댓글 수: 9
Walter Roberson
2021년 1월 31일
How did you do the forecasting with it?
Did you convert the date/time t numeric using datenum() ? If so, only do that if the forecasting routines do not support datetime objects, and otherwise use datetime() .
NN
2021년 1월 31일
yes, i converted using datenum()
Data=readtable('data.xlsx');
testdates = Data{1:end,1};
date_num = datenum(testdates);
date_num2 = datenum(testdates)+table2array(Data(1:end,2))./(24*3600);
NN
2021년 1월 31일
편집: NN
2021년 1월 31일
but it appears like serial numbers :i want to convert it to date and time format :i tried the below code but unable to plot since it is character array(pic attached) :If i convert it to double again it becomes NAN since it has string values:

o=datestr(in);
S = double(out);
S1=datestr(S);
figure
plot(out)
hold on
plot(in,'.-')
hold off
Walter Roberson
2021년 1월 31일
date_num2 = testdates + seconds(Data{:,2});
Now if possible use date_num2 in the forecasting, and plot with
plot(date_num2, in)
NN
2021년 1월 31일
thank you for your response.It worked for input date ,but didnt work for the output
out is date value generated after forecasting , and how can i convert this output back to date time format .
Walter Roberson
2021년 1월 31일
How are you generating the date value from forecasting ?
The values near 43878.4085416667 suggest to me,
datetime(43878.4085416667, 'convertfrom', 'excel')
ans = datetime
17-Feb-2020 09:48:18
but why are you getting Excel dates at all???
NN
2021년 1월 31일
i tried converting it to character array using below code ,
S = double(out);
S1=datestr(S);
but still not able to plot
채택된 답변
Walter Roberson
2021년 1월 31일
outd = datetime(out, 'convertfrom', 'excel');
plot(outd)
댓글 수: 10
Walter Roberson
2021년 1월 31일
Your code should be changed so that it does not produce Excel date numbers from the forecast. However, you are not being cooperative in identifying how it is getting Excel date numbers as output values, so I stopped caring.
Walter Roberson
2021년 1월 31일
The first step would be to describe how you are currently doing the forecasting. Which I already asked about twice before.
Walter Roberson
2021년 2월 1일
This is the information we, as outside observers, have so far:
- You have a datetime() vector named in
- Your results from your forecasting is named out
- Your results are in Excel date numbers
- You are using lstm forecasting.
(4) tells us that you must have created layers, and called trainNetwork(), and probably called predictAndUpdateState() https://www.mathworks.com/help/deeplearning/ug/time-series-forecasting-using-deep-learning.html
However, it does not tell us what you passed to trainNetwork(), and it does not tell us what layers you used.
So... we need to read your mind to figure that out. And when I read your mind, and your memory of what code you wrote, I figured out that your bug is in character #11 of line 7 of your code.
NN
2021년 2월 5일
so sorry ,
i tried to do LSTM in the same way as in https://www.mathworks.com/help/deeplearning/ug/time-series-forecasting-using-deep-learning.html
Walter Roberson
2021년 2월 5일
편집: Walter Roberson
2021년 2월 5일
I was right, the bug is in character #11 of line 7 of your code. (Prove me wrong!)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Manage Products에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)

