フィルターのクリア

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 Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by