how to calculate normalized cross correlations for two signals ????

49 views (last 30 days)
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

Accepted Answer

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy on 3 May 2018
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
  3 Comments
Rohan Dekate
Rohan Dekate on 17 Dec 2020
Hi
I implemented this for a sensor signal and a modelled signal, and got 0.847 as the answer. Correct me if I'm wrong in understanding the concept -
If the Normalized Cross Correlation is 1 it means that the two signals are matching each other and if it is 0 then they are not matching at all. Because it is normalized the answer will be between 0 and 1.
However, I have a simulink model from which I'm generating two signals as output. When I implemented the above formula I got 623700 as my answer which is not plausible at all. Can you tell me what has gone wrong?
Vasanthi Ravindran
Vasanthi Ravindran on 4 Feb 2022
Hi Yuvaraj Sir ,
Can you kindly send the formula for Normalised Cross Correlation

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!