How to find the best correlation between two signals?
(i know it has been discussed a lot elsewhere, but not in a concisely and efficiently manner).
So, I have:
X = the original signal
Y = a filtered version. They are similare but phase shifted.
I want to estimate the BEST correlation VALUE between X and Y within a maximum phase phase SHIFT=+-100 samples.
I would approach it this way:
l=xcorr( X,Y ); %% find all the lag/shift
index=find(al==max(al)); %% find the lag for which corr is max
lag = median( 1:length(al) ) - index;
%%%% shift Y2 accordingly to the value of lag
Y2=zeros(size( Y ));
if ( flag>0 && flag<SHIFT ) %% when the lad is a delay (+)
else if ( flag<0 && flag>-SHIFT ) %% when the lad is a anticipating (-)
'do nothing, cause the lag is greater than 100 samples'
Can you spot flaws in this technique?
Is there anything faster/more elegant?
Or simply, how would you do?
||8/25/2010 1:09:04 PM