How to calculate the circular correlation with 2 sequences/arrays in Matlab?
Mostrar comentarios más antiguos
Hello,
Trying to use Matlab to calculate the circular correlation between x = [2 3];, and y = [4 1 -8]; Unfortunately cannot find appropriate function, such as CXCORR or CIRCORR?
Can calulate using matlab Linear Correlation, Linear Convolution, Circular Convolution as follows:
EDU>> x = [ 1 3 5 ];
EDU>> y = [-2 2 4 6 8];
EDU>> convolution = conv(x,y)
convolution =
-2 -4 0 28 46 54 40
EDU>> a = [1 2 4];
EDU>> b = [-3 2 5 7 9];
EDU>> correlation = xcorr(a,b)
correlation =
9.0000 25.0000 55.0000 40.0000 21.0000 2.0000 -12.0000 0.0000 0
EDU>>
EDU>> x = [ 1 3 5];
EDU>> y = [-2 2 4 6 8];
EDU>> CircularConvolution = cconv(x,y,5)
CircularConvolution =
52 36 0 28 46
Appreciate any help.
kind regards. V.
2 comentarios
ankith sri
el 1 de Mzo. de 2021
To calculate circular correlation Lets consider a and b Flip b fliplr(b) And use cconv(a,b) Without giving the intervals, you will get the output for circular convolution
MEng - The more you learn the more you forget!
el 1 de Mzo. de 2021
Respuestas (1)
Honglei Chen
el 20 de Jul. de 2015
You can use
ifft(fft(a,5).*conj(fft(b,5)))
or
cconv(a,b([1 end:-1:2]),5)
HTH
2 comentarios
MEng - The more you learn the more you forget!
el 20 de Jul. de 2015
Editada: MEng - The more you learn the more you forget!
el 20 de Jul. de 2015
Honglei Chen
el 21 de Jul. de 2015
For this set of a and b, 6 points is already linear convolution, so there is no need to go through cconv although you could. The main issue here is the convention used in your book, which seems to consider moving to the left as index 1. In most literature I believe the convention is opposite. That's why you see the mismatch. Try the following:
fliplr(fftshift(cconv(a,fliplr(b))))
or
fliplr(circshift(ifft(fft(a,6).*conj(fft(b,6))),-1,2))
Categorías
Más información sobre Correlation and Convolution en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!