MATLAB: How to plot with YYYYMM date format on x-axis

date plot yyyymmMATLAB

LS,
I would like to plot some data with dates on the horizontal axis. The dates are in YYYYMM format.
When I plot the data set, there is a small horizontal space between e.g. 200911 and 200912. However, there is a large horizontal space between e.g. 200912 and 201001. It is clear why this happens…
Does someone probably have a solution for this issue? Should i convert the YYYYMM format to a date format which matlab understands? How? Or does an option for equidistantial horizontal spacing in graphs exists?
Your help would be very much appreciated.
Best regards,
Frits

Best Answer

This would convert your dates in YYYYMM format to serial dates which would have the correct intervals between the dates.
x = [200911 200912 201001 201002];
serialDates = datenum(num2str(x(:)), 'yyyymm')
Confirm with this:
datestr(serialDates)