0
$\begingroup$

I am having 2 sets of data data1 and data2 .I wanted to find the delay between the two datasets. Assume data1=[1 2 3 4 5 6 7 8 9 10] and data2=[0 0 0 0 1 2 3 4 5 6].From the data I know that, data2 is delayed by 4 samples.But to find the delay theoretically, I have applied cross correlation function.This was done in matlab using inbuilt function xcorr.The result xcorr(data1,data2) is as follows:[6 17 32 50 70 91 112 133 154 175 130 90 56 29 10 0 0 0 0].From this we can see the peak value 175 is at location 10 i.e at zero lag.So, how to estimate delay correctly

$\endgroup$
4
  • $\begingroup$ The cross correlation has 4 zeros at last, that's the delay you are looking for. $\endgroup$
    – ZR Han
    Jun 25, 2021 at 9:58
  • $\begingroup$ @ZRHan no that is not right. that is just a coincidence that is how xcorr chooses the lag window but in theory you could have lags from $-\infty$ to $\infty$. Additionally, it falls apart when noise is there. $\endgroup$
    – Engineer
    Jun 25, 2021 at 12:56
  • $\begingroup$ @Engineer yes I think you are right! $\endgroup$
    – ZR Han
    Jun 25, 2021 at 12:58
  • $\begingroup$ One of your signals goes to 10 and the other only goes to 6 so they're not going to match up $\endgroup$
    – endolith
    Jun 25, 2021 at 13:57

1 Answer 1

4
$\begingroup$

The issue is we are looking for likeness but the values are scaled beyond that metric. In the OP’s construct all symbols used should have equal weight toward the correlation determination; for example, the symbol "1" matching symbol "1" should carry just as much weight as symbol "6" matching symbol "6", but in the cross correlation this would contribute 36 to the result while the former would only contribute 1!

A robust solution to this is to remap to unique symbols that would provide equal weight upon a match, and no contribution when mismatched (orthogonal).

For example, we can choose 11 rows of an 11 point DFT matrix to represent each orthogonal symbol, replacing each of the 11 symbols with the 11 sample sequence as follows:

$$s_x[m] = \sum_{n=0}^{10} \delta[n-m]e^{-j 2 \pi \frac{n}{11}x}$$

Thus each original symbol x is replaced with an 11 sample sequence of index m from 0 to 10.

For example, the original symbol "1" would be mapped to the sequence $s_1[m]$ as:

$$s_1[m] = [1, e^{-j \pi \frac{2}{11}},e^{-j \pi \frac{4}{11}}, e^{-j \pi \frac{6}{11}}, e^{-j \pi \frac{8}{11}},e^{-j \pi \frac{10}{11}},e^{-j \pi \frac{12}{11}},e^{-j \pi \frac{14}{11}},e^{-j \pi \frac{16}{11}},e^{-j \pi \frac{18}{11}},e^{-j \pi \frac{20}{11}}]$$

While the original symbol "6" would be mapped to the sequence $s_6[m]$ as:

$$s_6[m] = [1, e^{-j \pi \frac{12}{11}},e^{-j \pi \frac{24}{11}}, e^{-j \pi \frac{36}{11}}, e^{-j \pi \frac{48}{11}},e^{-j \pi \frac{60}{11}},e^{-j \pi \frac{72}{11}},e^{-j \pi \frac{84}{11}},e^{-j \pi \frac{96}{11}},e^{-j \pi \frac{108}{11}},e^{-j \pi \frac{120}{11}}]$$

And as such, each symbol in the OP's original sequence would be replaced with an 11 sample orthogonal code and the original length 10 sequence would become a length 110 complex sequence in this example. (Note the values given for the sequence $s_6[m]$ could also be equally expressed in their reduced form on the unit circle, for example $e^{-j\pi \frac{24}{11}} =e^{-j\pi \frac{2}{11}}$)

Alternatively Walsh codes using 11 binary sequences from $W_{16}$ or other orthogonal symbols could similarly be used. The point is to map to orthogonal codes which would each carry equal weight in their contribution to the delay estimate in the correlation computation (which is a sum of products).

Below shows the result using DFT symbol replacement:

correlation result

PSK symbols could also be used providing equal weight for all symbol matches but this would not have the benefit of zero correlation on the mismatches. The advantage is a single complex value can be used for each symbol and while it will also provide the correct delay result the disadvantage is that it won’t be as robust in the presence of noise.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.