Technical discussion about Matlab and issues related to Digital Signal Processing.
Dear all,
My purpose is to determine if there is a correlation between two signals. I need to find if
they are correlated with a positive correlation close to 1 or an opposite one close to -1.
How do I normalize the cross-correlation coefficient when the 2 signals have different lengths?
I would like to perform a cross correlation of two finite length sequences “x” and “y”.
Length of x and y are different. I made the following script in order to determine the maximum
coefficient of correlation and the position of the lag.
x=[1 0 1 0 2 0 2 0];
y=-[1 0 1 0 2 0 2 0 2];
[corr,lag]=xcorr(x,y,'none');
[maximo,index] = max(corr);
[minimo,index2] = min(corr);
if abs(maximo)<abs(minimo);
max_corr=minimo; %Value of maximum correlation
lag_corr=lag(index2); %Corresponding lag of maximum correlation
else
max_corr=maximo;
lag_corr=lag(index);
end
subplot(3,1,1),plot(x,'-o'),ylabel('amplitude'),xlabel('time),
subplot(3,1,2),plot(y,'-o'),ylabel('amplitude'),xlabel('time');
subplot(3,1,3),plot(lag,corr,'-o'),hold on, plot(lag_corr,max_corr,'ro'),ylabel('correlation
without normalization'),xlabel('lag');
In fact, this script gives the maximum correlation coefficient and its corresponding lag:
max_corr =
-11
lag_corr =
-2
What does mean this max_corr here? How do I normalize the correlation coefficients? If I use
the option:
[corr,lag]=xcorr(x,y,'coeff'), it gives me the correlation coefficients normalized, but this
option is just for vectors with the same length and this is not my case.
I would greatly appreciate some help and advice ….
C.
Dear all, > >My purpose is to determine if there is a correlation between two signals. I need to find if they are correlated with a positive correlation close to 1 or an opposite one close to -1. > >How do I normalize the cross-correlation coefficient when the 2 signals have different lengths? > >I would like to perform a cross correlation of two finite length sequences “x” and “y”. Length of x and y are different. I made the following script in order to determine the maximum coefficient of correlation and the position of the lag. > >x=[1 0 1 0 2 0 2 0]; >y=-[1 0 1 0 2 0 2 0 2]; >[corr,lag]=xcorr(x,y,'none'); >[maximo,index] = max(corr); >[minimo,index2] = min(corr); >if abs(maximo) *************************************************** Hello, one idea is the following: 1)Let the two vectors be x and y and without loss of generality let length(x)<length(y). Extend periodically x until it's length equals the length of y, namely length(x_extended)==length(y). 2)run the command cross = xcorr(x_extended,y,'coeff'); and you have an approximation of the cross-correlation between x and y Manolis C. Tsakiris