Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8964 > unrolled thread

Re: maximize crosscorrelation

Started byBill Rowe <readnews@sbcglobal.net>
First post2012-03-11 09:10 +0000
Last post2012-03-13 08:01 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: maximize crosscorrelation Bill Rowe <readnews@sbcglobal.net> - 2012-03-11 09:10 +0000
    Re: maximize crosscorrelation alexxx <alexxx.magni@gmail.com> - 2012-03-13 08:01 +0000

#8964 — Re: maximize crosscorrelation

FromBill Rowe <readnews@sbcglobal.net>
Date2012-03-11 09:10 +0000
SubjectRe: maximize crosscorrelation
Message-ID<jjhq5j$ivq$1@smc.vnet.net>
On 3/10/12 at 6:16 AM, alexxx.magni@gmail.com (alexxx) wrote:

>I have two similar signals s1 and s2, where one is shifted with
>respect to the other by an unknown amount. These signals are
>captured by an oscilloscope, so you can represent them as arrays of
>{t,v} time and voltage values.

>I always knew that the theory says in such cases you have to
>maximize the selfcorrelation between the two signals, but I never
>used it until now.

>(BTW I was surprised to find that Mathematica had it as a standalone
>function, but doesnt provide it anymore)

>Anyway, 1st thing since crosscorr requires integration I defined the
>interpolation functions f1= Interpolation[v1];  f2=
>Interpolation[v2];

For discrete data the function you want is ListCorrelate. For example,

First generate a "signal" and the same signal with an offset:

x = RandomReal[1, {20}];
y = RotateLeft[x, 5];

Now find the offset by:

In[12]:= Ordering[
  Flatten@Table[ListCorrelate[RotateLeft[x, n], y], {n, 20}], -1]

Out[12]= {5}

[toc] | [next] | [standalone]


#8985

Fromalexxx <alexxx.magni@gmail.com>
Date2012-03-13 08:01 +0000
Message-ID<jjmut5$cdp$1@smc.vnet.net>
In reply to#8964
On 11 Mar, 10:10, Bill Rowe <readn...@sbcglobal.net> wrote:
> On 3/10/12 at 6:16 AM, alexxx.ma...@gmail.com (alexxx) wrote:
>
> >I have two similar signals s1 and s2, where one is shifted with
> >respect to the other by an unknown amount. These signals are
> >captured by an oscilloscope, so you can represent them as arrays of
> >{t,v} time and voltage values.
> >I always knew that the theory says in such cases you have to
> >maximize the selfcorrelation between the two signals, but I never
> >used it until now.
> >(BTW I was surprised to find that Mathematica had it as a standalone
> >function, but doesnt provide it anymore)
> >Anyway, 1st thing since crosscorr requires integration I defined the
> >interpolation functions f1= Interpolation[v1];  f2=
> >Interpolation[v2];
>
> For discrete data the function you want is ListCorrelate. For example,
>
> First generate a "signal" and the same signal with an offset:
>
> x = RandomReal[1, {20}];
> y = RotateLeft[x, 5];
>
> Now find the offset by:
>
> In[12]:= Ordering[
>   Flatten@Table[ListCorrelate[RotateLeft[x, n], y], {n, 20}], -1]
>
> Out[12]= {5}

works perfectly, thanks a lot!

alessandro

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web