How to generate quarterly date in Matlab?
65 views (last 30 days)
Show older comments
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 Comments
dpb
on 6 Jul 2020
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
>>
Answers (1)
dpb
on 6 Jul 2020
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 Comments
See Also
Categories
Find more on Time Series Events in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!