Changing numbers to actual dates
2 ビュー (過去 30 日間)
古いコメントを表示
So I have a set of data for example
A = [4 6 3 6 2 7 3 7 8 10]
with time steps
T = [0 28 56 91 119 147 161 175 203 231]
Where the timesteps correspond to months, so 0 is 7th july, 28 is 4th August and so on.
I can plot these graphs, but I would like the numbers to correspond to the actual dates. How can I do this?
0 件のコメント
採用された回答
dpb
2018 年 4 月 11 日
>> DT=datetime(2018,7+T.',7)
DT =
10×1 datetime array
07-Jul-2018
07-Nov-2020
07-Mar-2023
07-Feb-2026
07-Jun-2028
07-Oct-2030
07-Dec-2031
07-Feb-2033
07-Jun-2035
07-Oct-2037
>>
Oooops! T (as I kinda' thought) isn't in months; it's days...so
>> DT=datetime(2018,7,7+T.')
DT =
10×1 datetime array
07-Jul-2018
04-Aug-2018
01-Sep-2018
06-Oct-2018
03-Nov-2018
01-Dec-2018
15-Dec-2018
29-Dec-2018
26-Jan-2019
23-Feb-2019
>>
Ah! That looks more realistic!
3 件のコメント
dpb
2018 年 4 月 11 日
timedate is quite "ripe" yet; there are still holes that need filling. I suggest throw an enhancement request over the wall via official support link just to get it on record somebody wanted the feature with time axes.
The workaround is to revert to the venerable datenum; it is just a double of a specific magnitude. Then, of course, you have to revert to datetick to get the axis displayed as calendar times; somewhat klunky but it does work.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!