How to synchronize matrices (timeseries)?
이전 댓글 표시
May Somebody help me solve this problem?
I retrieved stock data from Yahoo and stored it in matrices, every matrix consists of 6 Columns (date,open,high,low,close,volume) and N time steps in the rows (daily).
conn = yahoo('http://download.finance.yahoo.com');
DBK=fetch(conn,'DBK.DE',{'Open', 'High', 'Low','Close','Volume'},'Jan 01 2005','Dec 31 2010', 'd')
DTE=fetch(conn,'DTE.DE',{'Open', 'High', 'Low','Close','Volume'},'Jan 01 2005','Dec 31 2010', 'd')
You will notice that both matrices do not have the same amount of rows DBK<1547x6>; DTE<1528x6>
Hence I cannot compare them, since there are some missing values in DTE. But since I got the date ID in column 1 of each matrix I would like to have the intersection between both matrices based on this ID. Can you help me? And is it possible to compute the intersection for more than 2 matrices?
Help is greatly appreciated!
채택된 답변
추가 답변 (3개)
Fangjun Jiang
2011년 9월 15일
Did you try intersect()?
A=[(1:10)', rand(10,1)];
B=[(5:15)', rand(11,1)];
[C,IndA,IndB]=intersect(A(:,1),B(:,1));
A_Selected=A(IndA,:)
B_Selected=B(IndB,:)
Léon
2011년 9월 26일
댓글 수: 2
Fangjun Jiang
2011년 9월 26일
Please post this as a separate question.
And you need to take a second look at the question. None of the variable N, data are given so others won't be able to run the code.
What is AnB = intersect(data{n,1}(:,1),data{n,1}(:,1))?
Do you mean AnB = intersect(data{n,1}(:,1),data{n,2}(:,1))?
Léon
2011년 9월 26일
카테고리
도움말 센터 및 File Exchange에서 Time Series에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!