From: david on
Hi, i have a big signal (corrupted by noise) in which i should find a pattern.

I have read something about using xcorr but i do not exactly how to use it.
what should i look for in x = (xcorr ( pattern,signal)) ?



My pattern will be 7 square pulses with a frequency of 1040 Hz

Please let me know how to use xcorr

Thank you very much
From: us on
"david " <int78005(a)stud.uni-stuttgart.de> wrote in message <i0t3g5$40c$1(a)fred.mathworks.com>...
> Hi, i have a big signal (corrupted by noise) in which i should find a pattern.
>
> I have read something about using xcorr but i do not exactly how to use it.
> what should i look for in x = (xcorr ( pattern,signal)) ?
>
>
>
> My pattern will be 7 square pulses with a frequency of 1040 Hz
>
> Please let me know how to use xcorr
>
> Thank you very much

a hint:
- an excellent place to start with...

doc xcorr;

us
From: david on
Thank you very much, i started to read that...

The main problem is that i can not interpret the results.

For instance:
x = [ 1 2 3]
y = [1 2 4]
z= xcorr(x,y) =4.0000 10.0000 17.0000 8.0000 3.0000

Why the number is bigger in the position 3?
From: Wayne King on
"david " <int78005(a)stud.uni-stuttgart.de> wrote in message <i0t564$kok$1(a)fred.mathworks.com>...
> Thank you very much, i started to read that...
>
> The main problem is that i can not interpret the results.
>
> For instance:
> x = [ 1 2 3]
> y = [1 2 4]
> z= xcorr(x,y) =4.0000 10.0000 17.0000 8.0000 3.0000
>
> Why the number is bigger in the position 3?

Hi David, position "3" actually corresponds to lag 0. You can see that if you compute

[c,lags] = xcorr(x,y);

It's maximum there because the element-by-element product and sum is the largest when these vectors are not shifted with respect to each other

sum(x.*y)

Wayne
From: ImageAnalyst on
There are 5 places where the two arrays overlay as you shift one past
the other. When the overlap is complete (for the third shift), the
product is 1*1 + 2*2 + 3*4 = 17

shift of 1, sum of products = 4

1_2_4
____1_2_3

Shift of 2, sum of products = 10
__1_2_4
____1_2_3

Shift of 3, sum of products = 17
____1_2_4
____1_2_3

Shift of 4, sum of products = 8
______1_2_4
____1_2_3

Shift of 5, sum of products = 3
________1_2_4
____1_2_3

It assumes that where there is no overlap, the product is zero for
those elements. Note that the cross correlation does not always give
the maximum at the shift of complete overlap, and there are many
places where one array is "inside" the other when one array is longer
than the other (many places with "complete" overlap).