0
$\begingroup$

I want to find the shift between 2 signals $\sin a$ and $\sin b$ where (with Matlab code)

$$ a = \{0, 1,2,3,4\} $$ $$ b = a +1 $$ $$ \implies b = \{1,2,3,4,5\} $$ then $$ \arg\max \sin a = 2 $$

enter image description here and $$ \arg\max \sin a = 3 $$ Their shift is then 1.

enter image description here

However if I'm trying to compute their cross correlation (using Matlab), I get the argmax at 7 and not at 1

a = 0:1:5
b = a + 1
[argvalue, argmax] = max(xcorr(sin(a), sin(b)))

enter image description here

What am I missing (probably something very basic... many thanks in advance)

$\endgroup$
  • $\begingroup$ Welcome to SE.SP! I'm assuming your second plot is $\arg \max \sin b$ not $\arg \max \sin a$? The correlation $x$-axis will be from -5 to +5, to the 6 in your final plot should be the origin (0). $\endgroup$ – Peter K. May 19 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.