find best correlation

  • Follow


Hi there,
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
SHIFT=100;
Y2=zeros(size( Y ));
    if ( flag>0 && flag<SHIFT )   %% when the lad is a delay (+)

    Y2(lag:end)=Y(1:end-flag);
    FINAL_CORR_VALUE=corr(X,Y2)

else if  ( flag<0 && flag>-SHIFT ) %% when the lad is a anticipating (-)

    Y2(1:end-lag)=Y(lag:end);
    FINAL_CORR_VALUE=corr(X,Y2)
else
 'do nothing, cause the lag is greater than 100 samples'
end

Can you spot flaws in this technique?
Is there anything faster/more elegant?
Or simply, how would you do?
0
Reply stefano 8/25/2010 1:09:04 PM


0 Replies
272 Views

(page loaded in 0.009 seconds)

Similiar Articles:













7/25/2012 6:26:06 PM


Reply: