現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)

