This code snippet
Data=readtable('2019_SysLoad.xlsx');
testdates=Data((5834:end),1);
A = table2array(testdates);
plot(datetime(A),target_test);
is unclear. It seems you are reading a spreadsheet into a table, getting a one-var table from that, converting that to the raw data, converting that to datetime, and plotting.
For one thing, this seems simpler:
Data=readtable('2019_SysLoad.xlsx');
A = Data.SomeVarName(5834:end);
plot(datetime(A),target_test);
I guess the first var in your table is, what, text timestamps? That's the only way I can make sense of datetime(A). In which case, I'd suggest working with a timetable, something like this:
tt = table2timetable(Data(:,2:end),'RowTimes',datetime(Data.SomeVarName))
I also have no idea what else is in Data, or indeed where target_test is coming from. It would seem logical that target_test would be extracted from Data.
So OK, you have a datetime and you plot you target_test against that, and you get a nice plot. But it seems like you are wanting to have a plot against some kind of elapsed time. I don't know where, say, 200 comes from. Maybe it's a number of elapsed days since ... something? They don't seem to be row numbers.
Try subtracting your origin datetime from A, and setting the resulting duration's format to 'd'.
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/625248-how-to-plot-forecasted-data-with-corresponding-dates#comment_1084363
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/625248-how-to-plot-forecasted-data-with-corresponding-dates#comment_1084363
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/625248-how-to-plot-forecasted-data-with-corresponding-dates#comment_1085788
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/625248-how-to-plot-forecasted-data-with-corresponding-dates#comment_1085788
Sign in to comment.