X-axis dates are wrong in Matlab plot -


my dates in format 'yyyymmdd'. when put these onto x-axis of plot, crazy numbers. plot interval last decade, x-axis tick labels showing 1979 , other weird numbers. can point me in right direction correct this? thanks.

edit: here requested code:

tradedate=tradedate+693960; % convert excel serial dates matlab serial dates tradedate=datestr(tradedate,'mmddyyyy'); % convert format yyyymmdd tradedate=str2double(cellstr(tradedate)); % convert date strings first cell arrays , double  plot(tradedate,beta); xlabel('date'); ylabel('beta'); daspect([300 1 1]); set(gca,'xtick',linspace(tradedate(1),tradedate(1715),50)); ax=gca; ax.xticklabelrotation=45; 

what doing plotting serial date numbers on x-axis, when suspect want plot date strings themselves.

as such, use serial date numbers spawn plot first, use date strings changing x-axis labels. btw, code using str2double rather pointless because if follow comment on first line of code correctly, already serial date.

something this:

tradedate=tradedate+693960; % convert excel serial dates matlab serial dates  %// note change in variable name here , convert cell array of strings tradedates=cellstr(datestr(tradedate,'mmddyyyy')); % convert format mmddyyy  plot(tradedate,beta); xlabel('date'); ylabel('beta'); daspect([300 1 1]); set(gca,'xtick',linspace(tradedate(1),tradedate(1715),50)); %// change - change x-axis labels set(gca, 'xticklabel', tradedates(1:50:1715)); ax=gca; ax.xticklabelrotation=45; 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -