필터 지우기
필터 지우기

Cross-correlation without using xcorr (vectorized)

조회 수: 12 (최근 30일)
Albert Zurita
Albert Zurita 2022년 7월 4일
편집: Albert Zurita 2022년 7월 4일
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개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by