필터 지우기
필터 지우기

correlation of signals

조회 수: 2 (최근 30일)
Padma
Padma 2011년 11월 10일
HI
I have used the following code to compute correlation:
[FileName,PathName] = uigetfile('mitsplit_00_(Left)[1]');
PathOriginal=sprintf('%s%s',PathName,FileName);
[xt,fs]=wavread(PathOriginal);
[FileName,PathName] = uigetfile('mitsplit_01_(Right)[1]');
PathOriginal1=sprintf('%s%s',PathName,FileName);
[yt,fs]=wavread(PathOriginal1);
fs=8000;
[c,lags]=xcorr(xt,yt)
the problem with this is it is printing so many values that i cannot find the maximum value and get the corresponding lag value.
I just started matlab recently. Please excuse me if my doubt is silly.
Thanks in advance

답변 (2개)

Wayne King
Wayne King 2011년 11월 10일
Don't leave the semicolon off. And look for where the maximum occurs.
x = cos(pi/4*n);
y = cos(pi/4*n-(3*pi)/4);
[c,lags] = xcorr(y,x,'coeff');
[maxcorr,I] = max(c);
fprintf('The maximum occurs at lag %d\n', lags(I))
  댓글 수: 2
Padma
Padma 2011년 11월 10일
[c,lags] = xcorr(y,x,'coeff');
[maxcorr,I] = max(c);
could you please explain why we are using 'coeff' here and the next line also in more detail
Honglei Chen
Honglei Chen 2011년 11월 10일
You don't have to use 'coeff'. It is just a normalization. The next line is getting both maximum value and the index where that value happens. I think this is not the first time you ask about these lines so I would strongly suggest you to read the documentation for both xcorr and max, try out the examples and see the result. It is actually quite obvious if you put your hand on it.

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


Wayne King
Wayne King 2011년 11월 10일
You may also want to read over my examples in this thread:

카테고리

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