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 ?
adding year to plot using datetick
조회 수: 1(최근 30일)
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
xlabel('Trading days since 2000-01-03')
title('Particle filter estimate of volatility');
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);
John Petersen 2012년 7월 11일
편집: John Petersen 2012년 7월 11일
You have 1:iNumObs as the x-axis. I assume this is where you want the years. If your data is on a yearly basis, just add the first year (-1) to the x-axis
If your data is throughout the year but you just want a label for each year, then you need the date of each data point. If it's in datenum for example, then you can use datetick to convert to the format you're looking for,