Cross-correlation without using xcorr (vectorized)
18 次查看(过去 30 天)
显示 更早的评论
Hello, I cannot use xcorr built-in function and I will correlate two discrete signals directly in my code. I have seen some answers pointing to some FileExchange submissions that go over a nested for-for loop to do the computations. This is maybe faster, I don't doubt, but I would like to do the computation with a single for. I am trying the following, where the plots show the comparison between my method with xcorr and with frequency-domain correlation. I see non-negligible differences with my code...by the way there seems to be a lag between the xcorr and frequency domain correlation.
b0 = [block0 zeros(1,bsize)];
b1 = flip([conj(blockWPC) zeros(1,bsize)]);
clear bf;
for k=1:(2*bsize)
bf(k) = sum(b0.*circshift(b1,k));
end
plot(abs(ifftshift(ifft(fft(block0,2*bsize).*conj(fft(blockWPC,2*bsize))))),'*-');hold on;
plot(abs(xcorr(block0,blockWPC)),'o-');
plot(abs(bf));
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!