MATLAB: Does DATETICK round and interpolate the dates in MATLAB 7.9 (R2009b)

MATLAB

I plot TIMESERIES and chose a date format to display date and time (e.g. 'dd-mmm-yyyy HH:MM:SS'):
xdate=datenum(['01-Mar-2008 15:45:17'; ...
'01-Mar-2008 18:31:01'; ...
'01-Mar-2008 21:31:59'],0);
plot(xdate,1:3)
datetick('x',0)
The resulting plot has date ticks rounded to full hours and extrapolated.

Best Answer

When the number of values in a plot exceeds the number of date strings that can be placed as ticks, DATETICK needs to run a heuristic to place appropriate ticks.
You can suppress this behavior using the KEEPLIMITS and KEEPTICKS options. For example, you can explicitly set the desired TICKS before calling DATETICK as follows:
plot(xdate,1:3)
set(gca,'Xtick',xdate)
datetick('x',0,'keeplimits','keepticks')