How to convert numerical dates to conventional dates
이전 댓글 표시
I have imported a spreadsheet historic stock prices for a stock (ticker CHK) into Matlab using the importfile function. The goal is to plot the price movements, and volume movements and to show the conventional dates labeled on the x-axis.
When I imported the spreadsheet, the Date column converted to a number (for example August 17, 2011 reads 40772). I converted the numerical date to a conventional date and wrote it into Excel using the datestr function, and the xlswrite function. The conventional date can now be seen on the spreadsheet outside of Matlab; however, the variable cDate (conventional date) in the workspace shows this symbol { }cDate, instead of a grid like the other variables and I can't plot it.
Here are the functions I've used to get this far.
importfile('chk.xls');
cDate = Date;
cDate = x2mdate(cDate, 0);
str = datestr(cDate, 1);
cDt = cellstr( str );
I want the cDt cell array to convert into a double vector of the same size. I.e, in the workspace, all the variables are a double vector of the same size < 254x1 double >, except cDt, which reads < 254x1 cell >. I am not sure what I need to do to accomplish this. Essentially I want to graph a stock price movement from Aug 31, 2011 to Aug 31, 2012 and I want the x-label to read the day, month etc, versus the Matlab serial number.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!