syedshan
Advanced Member level 1
- Joined
- Feb 27, 2012
- Messages
- 463
- Helped
- 27
- Reputation
- 54
- Reaction score
- 26
- Trophy points
- 1,308
- Location
- Jeonju, South Korea
- Activity points
- 5,134
Dear all,
I am was not convinced or may be could not understand the correlation in matlab i.e. xcorr function.
So to test I simple made two exactly similar sine wave without any delay, and it gives me delay of 21.
I cannot understand why. please first see the code below
So I get the delay at the index 21, where I think we should not have any delay. Note that the x and y both have 21 elements.
What I understand is, may be matlab implicitly padd zeros to the second element, in this case y,
Also the please clarify one more thing that the maximim value in the vector 'xc' indicates that at this point the peaks of the two points come together right...!
Thanks in advance,
Shan
I am was not convinced or may be could not understand the correlation in matlab i.e. xcorr function.
So to test I simple made two exactly similar sine wave without any delay, and it gives me delay of 21.
I cannot understand why. please first see the code below
Code:
fo=200; fs=2500;
t=0:1/fs:.008;
x=sin(2*pi*fo*t);
y=x; %now x and y are exactly the same
%correlation start here
xc = xcorr(x,y);
[a,delay]=max(xc);
subplot(3,1,1); plot(t,x); %xlabel(t);
subplot(3,1,2); plot(t,y);
subplot(3,1,3); plot(xc);
display(sprintf('maximum of xc is %d',max(xc)));
display(sprintf('delay is %d',delay));
So I get the delay at the index 21, where I think we should not have any delay. Note that the x and y both have 21 elements.
What I understand is, may be matlab implicitly padd zeros to the second element, in this case y,
Also the please clarify one more thing that the maximim value in the vector 'xc' indicates that at this point the peaks of the two points come together right...!
Thanks in advance,
Shan