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!