How to synchronize matrices (timeseries)?
Mostrar comentarios más antiguos
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!
Respuesta aceptada
Más respuestas (3)
Fangjun Jiang
el 15 de Sept. de 2011
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
el 16 de Sept. de 2011
0 votos
Léon
el 26 de Sept. de 2011
2 comentarios
Fangjun Jiang
el 26 de Sept. de 2011
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
el 26 de Sept. de 2011
Categorías
Más información sobre Time Series en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!