MATLAB: Plotting a graph of a date !!

2-ddatenumdatetickgraphplot

I am trying to plot a graph of the amount of rain over one year ( 12 months) using the code below, but the problem is that only 3 months appear on the graph ( Jan, Feb and March) and I have no I idea where I went wrong !!
startDate = datenum('Oct 1991');
endDate = datenum('Sep 1992');
xData = linspace(startDate,endDate,12);
plot(xData,Max_rain)
datetick('x','mmm')

Best Answer

'Oct 1991' and 'Sep 1992'
are not a valid format for a date string so these get interpreted totally differently to what you expect.
doc datenum
has a big section on the valid formats for DateString. e.g.
startDate = datenum('1-Oct-1991');
So far as I can see you cannot have a date that does not include a day so I guess you can just pick whatever day suits you for each month.
You can do something like this:
startDate = datenum('Oct/1991', 'mmm/yyyy' )
but
datestr( startDate )
will still default to:
01-Oct-1991
because to create the date it also specifies a number.