How to calculate the circular correlation with 2 sequences/arrays in Matlab?
이전 댓글 표시
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
ankith sri
2021년 3월 1일
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!
2021년 3월 1일
답변 (1개)
Honglei Chen
2015년 7월 20일
You can use
ifft(fft(a,5).*conj(fft(b,5)))
or
cconv(a,b([1 end:-1:2]),5)
HTH
댓글 수: 2
MEng - The more you learn the more you forget!
2015년 7월 20일
편집: MEng - The more you learn the more you forget!
2015년 7월 20일
Honglei Chen
2015년 7월 21일
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))
카테고리
도움말 센터 및 File Exchange에서 Correlation and Convolution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!