MATLAB: Xtick string with plot yy

plotyy

From the following example how would I show the time denoted by 'out' along the xaxis:
clear all
time = (0:23)';
n = numel(time);
out = cellstr(datestr([ones(n,1)*[2012 3 10] time zeros(n,2)],'HH:MM'));
%data
data1 = rand(24,1);
data2 = rand(24,1);
plotyy(time,data1,time,data2);
I have tried
set(gca,'XTickLabel',out);
But it does not work. How would I generate a plot similar to the one shown above but with the time i.e. from 00:00 to 23:00 along the xaxis?

Best Answer

replace the call to plotyy with following:
h = plotyy(time,data1,time,data2);
set(h,'XTickLabel','');
set(h,'XTick',0:23);
set(h,'XTickLabel',out);