Cross-correlation maximum in frequency domain

I need to compute the complex cross-correlation between two signals a and b and the take only the maximum value of the cross-correlation, regardless of the lag time where this occurs. I can do it either in time domain or in frequency domain. This needs to be later incorporated in a FPGA, so I want to be efficient.
An alternative is to go to frequency domain correlation, but I would need to do
max(IFFT(FFT(a)*conj(FFT(b))))
which is probably computationally costly. Is there a way to avoid going back and forth twice to the frequency and time domain and still compute the maximum cross-correlation?
thanks

Respuestas (1)

vidyesh
vidyesh el 19 de Oct. de 2023
Hi Albert,
I understand that you want to calculate the maximum value of the cross-correlation of two signals in an efficient manner.
To accomplish this task, you can utilize the 'xcorr' function in MATLAB. This function enables the computation of the cross-correlation between two discrete-time sequences. The following code snippet demonstrates how to obtain the desired value:
val = max(xcorr(a,b));
It's important to note that if you intend to calculate the value using the method mentioned in the question, which involves "max(IFFT(FFT(a)*conj(FFT(b))))", you will need to apply "zero-padding" to both signals beforehand. After padding, the length of the cross-correlation between 'a' and 'b' should be equal to the sum of the lengths of 'a' and 'b' minus one (length(a) + length(b) - 1).
aa = [a zeros(1, length(b) - 1)];
bb = [b zeros(1, length(a) - 1)];
val = max(ifft(fft(aa).*conj(fft(bb))));
Refer to the following documentation for more information:
Hope this answer helps.

2 comentarios

Albert Zurita
Albert Zurita el 24 de Oct. de 2023
excellent, thank you!
Rochelle
Rochelle el 9 de Feb. de 2024
Vidyesh, Within the xcorr function both x and y are converted to fft and then back to ifft after multiplication. So, by using xcorr function, I dont think it will solve the problem. It will still be computationaly expensive.

Iniciar sesión para comentar.

Productos

Versión

R2021a

Preguntada:

el 23 de Feb. de 2022

Comentada:

el 9 de Feb. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by