MATLAB: How to calculate normalized cross correlations for two signals ???

correlationcross correlationhelplag_signalnormalizednormalized cross correlationsignal processing

hello
I hope you are doing well and fine
i have two arrays of data for two different signals
i want to compare them using cross correlations
xcorr method is used to get the correlation value and then lag value and i plot it using this code
[tmpr lags]=normxcorr2(powersignal1,power_b_int);
[tmpr1 lags1]=normxcorr2(powersignal1,powerT1);
my problem is that i want to do a normalized cross-correlation as it is more exact and gives better results however i do not know how to do so
is there a function in Matlab that does normalized cross-correlations calculations for different lags and return the results ??
i have been searching for a while yet i could find any
i know the formula for calculating the normalized cross-correlations but hoped for a prepared method to use right a way instead of writting the method thank you so much

Best Answer

Check this, where x and y are two vector with length N.
if true
Normalised_CrossCorr = (1/N)*sum((x-mean(x))*(y-mean(y)))/(sqrt(var(x)*var(y));
end
Related Question