Possible to vectorize xcorr?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Greetings.
Currently my workstation can't keep up when I attempt to calculate the cross correlation for very long signals.
This is a MWE of the code:
x = rand(1,200e3);
for i=500:-1:1
y = i.*x;
C(i,:) = xcorr(x, y, 500);
end
The 500 calls to xcorr seems to kill it. Any way to improve this by vectorizing or otherwise optimize it? Currently it takes >60 sec which isn't practical.
I'm only interested in a small number of lags (around ±500). So I attempted to do a classic implementation of the cross correlation instead of the Fourier implementation in xcorr. My end result wasn't an improvement, but maybe you guys/gals can do one better?
Thanks for any ideas!
1 Kommentar
Daniel Shub
am 3 Apr. 2013
I may be missing something, but x and y are scaled versions of each other. You just need to compute the autocorrelation of x once and then set the normalisation factor in the loop.
Antworten (1)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!