MATLAB: Adding year to plot using datetick

datetick

I have created a plot for a volatility measure, now i want to add the years of the measure to the x axis. I have the appropriate year in a .txt file which i have loaded into the variable 'dates'. However i can not get the labels onto my plot
plot(1:iNumObs,exp(vLogVolsBF),'r:')
xlabel('Trading days since 2000-01-03')
ylabel('Volatility')
title('Particle filter estimate of volatility');
datetick('dates','yyyy');
It returns the error:
??? Error using ==> datetick>parseinputs at 344 The axis must be 'x','y', or 'z'.
Error in ==> datetick at 109 [axh,nin,ax,dateform,keep_ticks,keep_limits] = parseinputs(varargin);
Thank you

Best Answer

Thank you for your answer, it is the second case that is relevant. My data consists of 3081 observations, having loaded the year for each observation into the variable 'dates' i thought i was trying to do exactly as you suggest using datetick('dates','yyyy'); after my plot ?
Related Question