Correlation (cor) vs. Covariance (cov)
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all,
does someone know why to compute a loop with the cor function takes way longer than doing it with the cov function?
I've the followin loop
covC = cell(szX(1),1);
CovM = zeros(szX(1),szX(2));
for n = ws1+1:szX(1)
covC{n} = cov(((logr(n-ws1:n,:))));
CovM(n,:)= (covC{n}(1,:));
end
the matrix is ca. (1580x32)... if u run the posted loop it takes just a few seconds. However If I want to compute the correlation (and substitute cov with cor) it takes about 5 minutes
corC = cell(szX(1),1);
CorM = zeros(szX(1),szX(2));
for n = ws1+1:szX(1)
corC{n} = corr(((logr(n-ws1:n,:))));
CorM(n,:)= (corC{n}(1,:));
end
. I want to do it also with a 3000x1200 matrix
can someone suggest me a quicker prodecure to achive my goal?
thaks for ur hepl
2 comentarios
Oleg Komarov
el 1 de Mayo de 2011
You can use the compiler to verify where are the bottlenecks in corr as compared to corrcoeff.
Respuestas (0)
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!