How to use xcorr function in matlab as autocorr

조회 수: 6 (최근 30일)
Tamil selvan
Tamil selvan 2016년 11월 21일
댓글: Image Analyst 2016년 11월 22일
Hello all,
I am trying to use the xcorr() function as an autocorrelation function in Matlab. But I am getting the wrong output. Can any one correct me if I am doing any mistake in the below procedure?
I am doing auto-correlation with the shift of 24(i.e. every samples is correlated with the 25th samples) using the function given below,
out= xcorr(x, 24); //assume x is a complex variables.

답변 (2개)

Greg Dionne
Greg Dionne 2016년 11월 21일
out = xcorr(x,x(25:end))

Image Analyst
Image Analyst 2016년 11월 21일
The two slashes need to be replaced by a percent symbol, which is a comment indicator in MATLAB.
To autocorrelate x, you need to pass in x twice:
out= xcorr(x, x) % Assume x is a complex variables.
I don't know what you mean by a shift of 24. As you know, autocorrelation shifts one array by all possible shifts that result in an overlap of the signals, so basically the result is an array that is as long as the sum of the two lengths of the component vectors. If you want a shift of 24, simply pick out that element.
  댓글 수: 2
Tamil selvan
Tamil selvan 2016년 11월 22일
편집: Image Analyst 2016년 11월 22일
Sorry for confusing.
a = repmat((1:9).*(1+1i), 1, 10);
/************** AutoCorrelation Function ***********
for m=1:10;
out1(m) = a(m) .* conj(a(m+24));
end
******************************************************
I tried to implement the above function using xcorr function. That's why I mentioned 24 shift the previous comment.
Image Analyst
Image Analyst 2016년 11월 22일
Why is that "wrong"? It does what you told it to do. It's not an autocorrelation but it's doing what you tell it to.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by