MATLAB: Is it actually possible to use datetick

datenumdatetickdatetimexaxis

I have a cell array of timestamps with the format:
'2014-10-06 09:27:34'
I converted this to a datetime type using:
t = datetime(Date, 'InputFormat', 'yyyy-MM-dd HH:mm:ss');
Then, I made this into a DateNumber, so I could use it as the x-axis for a plot:
DateNumber = datenum(t);
plot(DateNumber, myData)
I tried to convert the x-asix to something readable using datetick. I only care about the hours, minutes and seconds , so I entered:
datetick('x', 'HH:mm:ss')
However, all my ticks say 00:10:00 no matter how I zoom in on the axis. Also, if I change the axis limits using the plot tool before I run datetick from the command line, it reverts to the old axis limits.
I tried plotting a small subset of my data (80 points) that was taken between 4:52:56 and 6:25:46. My plot only gets five ticks, 04:10:00, 05:10:00, 05:10:00, 06:10:00 and 06:10:00. How are these 'repeat' ticks possible?
If I look at the contents of DateNumber using datestr:
datestr(DateNumber(2550))
ans =
08-Oct-2014 04:52:56
I get back the values I expect, so it looks like the DateNumber variable is filled properly. The problems seem to be with datetick.

Best Answer

With datetimes, if you plot them it takes care of datetick for you:
plot(t)
It's a new feature in 14b and it will update when you zoom.