How to generate quarterly date in Matlab?
93 次查看(过去 30 天)
显示 更早的评论
I need to plot timeseries plot of different macroeconomic variables from 1966Q2 to 2020Q1. I used the code ts= 1966Q1: 2020Q1. But I get bugging all the time.
2 个评论
dpb
2020-7-6
Post actual code/error, not just description.
'1996Q1' is not a valid variable name nor a valid date...you could use it as an input string to create one as:
>> datetime('1966Q1','InputFormat','yyyy''Q''Q')
ans =
datetime
01-Jan-1966
>>
回答(1 个)
dpb
2020-7-6
datetick('x', 'mm/dd/yyyy');
is your problem. datetick is/was ONLY used for the deprecated datenum which was just a double in disguise.
When you plot() with datetime and/or duration variables, the x-axis is a 'DatetimeRuler' object.
You set the date format with it using the same formatting strings as datetime uses.
At
ax.XAxis
you'll get the handle to the XAxis object and can see all the properties for it...there's also a doc page for the plot() function for plotting datetime data.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Events 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!