correlation of signals
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (2)
Wayne King
el 10 de Nov. de 2011
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 comentarios
Honglei Chen
el 10 de Nov. de 2011
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
el 10 de Nov. de 2011
You may also want to read over my examples in this thread:
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!