Reputation: 974
I am trying to understand code written by my predecessor. Rather than using a xcorr in MATLAB, she did the following. Apparently this seems to working. I would really appreciate if someone could explain, what is happening here. She is saying the pattern is symmetric by calculating the variable sym below, in the code below.
close all hidden
t = 0:0.01:2*pi;
x = sin(t)
plot(x,'k')
mu = mean(x)
sigma = std(x)
y = (x-mu)/(sigma);
hold on
plot(y,'r')
yrev = y(end:-1:1);
hold on
plot(yrev)
hold on
sym = sum(y.*yrev/length(y))
plot(y.*yrev/length(y),'r*')
Upvotes: 0
Views: 750
Reputation: 11064
sym
is the normalised cross-correlation between y and the reverse of y.
sym
is close to one, y is a symmetric function.sym
is close to zero, y is an asymmetric functionsym
is close to minus one, y is a anti-symmetric functionEDIT: relation with xcorr
You would obtain the same result if you calculate sym
as follows:
sym = xcorr(y, yrev, 0, 'coeff')
Upvotes: 2