Importing from XLSX file, column dates, column data
이전 댓글 표시
Hello,
I am new to Matlab and I want to test the MACD rule on a dataset.
I downloaded the data into Excel and imported the data into Matlab
The first column gives the dates, ranging from 01-Jan-1990 to 18-May-2012. i changed these dates to numeric data in excel and then applied the following command in Matlab:
x = xlsread('x.xlsx')
Date(:,datecol) = Date(:,datecol) + datenum('30-Dec-1899');
D = datestr(x(:,1))
Now the problem is that Matlab creates a seperate variable containing the dates and this variable is an (ab) variable, but this type of variable is strange because i caanot plot it in combination with the share prices. how do I get the dates in a variable that i can work with?
Thanks in advance,
댓글 수: 3
Oleg Komarov
2012년 5월 27일
You mean it's a char variable?
Jelle
2012년 5월 27일
Oleg Komarov
2012년 5월 27일
You can right-click on the column headings of the workspace pane and select the voice 'Class'. It will tell which class the variable belongs to.
답변 (1개)
Oleg Komarov
2012년 5월 27일
0 개 추천
댓글 수: 5
Jelle
2012년 5월 27일
Jelle
2012년 5월 27일
Oleg Komarov
2012년 5월 27일
You can keep dates and data in one 'file' (do you mean variable?) as long as their types are consistent.
To be very intuitive, numbers are generally class double, while strings are generally class char.
You cannot have words mixed with numbers, therefore to keep them together dates should be stored as serial numbers.
What is DJ?
Note that to be able to specify the x-values you have to use the syntax
plot(x,y)
where x should be your xData.
Jelle
2012년 5월 27일
Oleg Komarov
2012년 5월 27일
Then you should just call:
plot(dates, DJ)
datetick()
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!