Correlation (cor) vs. Covariance (cov)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Oleg Komarov
le 1 Mai 2011
You can use the compiler to verify where are the bottlenecks in corr as compared to corrcoeff.
Réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!