The PLOTYY function creates two axes and the call to DATETICK in this case will only update the second axis with the dateticks. To workaround this issue, you can delete the xTicklabels on both axes and then update one of the axes with the dateticks as follows:
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
set(AX, 'xTickLabel','')
datetick(AX(1),'x',20,'keeplimits');
axis tight
To update the dateticks on every call to the ZOOM function, specify the 'ActionPostCallback' property of the ZOOM function:
h = zoom(gcf);
set(h,'ActionPostCallback',{@mypostcallback,AX});
set(h,'Enable','on');
Here the mypostcallback function updates dateticks on the first axis on every zoom.
function mypostcallback(obj,evd,AX)
datetick(AX(1),'x',20,'keeplimits');
Best Answer