# Golay complementary sequences for channel estimation - MATLAB

There are set of complementary sequences known as Golay sequences that are used for channel estimation because of the nice property they have which is that the sum of the autocorrelation function of each gives dirac function.

For example, these are two complementary sequences

$$Ga=[+1, +1, +1, −1, +1, +1, −1, +1]$$ $$Gb=[+1, +1, +1, −1, −1, −1, +1, −1]$$

$$R_a(i)+R_b(i) = \delta(i)$$

Due to this nice correlation property, they are used in digital communication for as known pilot sequences for channel estimation of wireless channel. For example assume the channel we want to estimate is $h(t)$ then sending $Ga$ and $Gb$ over channel first and then performing correlation at receiver with Ga and Gb provides a good estimate of channel.

$$(h(t)*Ga)*Ga + (h(t)*Gb)*Gb =h(t)*(R_a+R_b)= h(t) \delta(t)$$

In theory, this is easy to understand. However I am trying to implement a more realistic setup in MATLAB.

If $G_a$ and $G_b$ are 10 chip in length with have a chip time of $T_c=0.57 ns$ and the channel is a 2 tap with delay spread of the channel is $T_{delay}=2.7 ns$. And assume we have Additive White Gaussian noise. My aim to estimate the channel. Below is my code.

channel =[1 0.2]';
Ga=[+1, +1, +1, -1, +1, +1, -1, +1]';
Gb=[+1, +1, +1, -1, -1, -1, +1, -1]';
y1=conv(channel,Ga);
y2=conv(channel,Gb);
r1=awgn(y1,10);
y2=awgn(y2,10);
hac1 = dsp.Autocorrelator;
correlation_output1=step(hac1,Ga);
correlation_output2=step(hac1,Gb);
channel_estimation=correlation_output1+ correlation_output2;


As you can tell, I have not included the delay spread $T_{delay}$ neither the chip rate $T_c$. Can anyone help me understand how I can incorporate such in my MATLAB code?

• The absolute chip rate and delay spread isn't really relevant in a simulation like this. What's important is the delay spread as a fraction of your sample rate (I'm assuming you're at one sample per chip). The delay spread is conceptually the spread in time between the most direct propagation path and the multipath reflection that is received last. This maps to the length of your channel; if a chip is ~0.5 nanoseconds and the delay spread is 2.5-3.0 nanoseconds, then your channel needs to have a memory of 5-6 chips. – Jason R Jun 11 '15 at 12:22
• Actually let me re-phrase my question, you wrote in your comment sample rate (sample per chip) this confused me with the regular definition of sampling rate which is number of samples per second...@JasonR – Tyrone Jun 11 '15 at 14:39

I would try with this code:

channel =[1 0.2]';
Ga=[+1, +1, +1, -1, +1, +1, -1, +1]';
Gb=[+1, +1, +1, -1, -1, -1, +1, -1]';
y1=conv(channel,Ga);
y2=conv(channel,Gb);
correlation_output1=xcorr(y1,Ga);
correlation_output2=xcorr(y2,Gb);
channel_estimation=correlation_output1+ correlation_output2;
stem(channel_estimation./length(Gb))


Best regards,

• Maybe you could add some explanation why the OP should try that code. – Matt L. Jun 23 '15 at 16:04

I changed your code a little and I could estimate the channel.

channel = [1 0.2]';
Ga = [+1, +1, +1, -1, +1, +1, -1, +1]';
Gb = [+1, +1, +1, -1, -1, -1, +1, -1]';

correlation_Ga = xcorr(Ga, Ga);
correlation_Gb = xcorr(Gb, Gb);

temp = correlation_Ga + correlation_Gb;
y = conv(temp(length(Ga):end), channel);
y = y/length(Ga);


First I calculated the autocorrelation of both Ga and Gb. It is this sum that results in the impulse response. I think that you made a mistake writing the equation in your question. I think the right is:

$(h(t)*Ga)*Ga + (h(t)*Gb)*Gb =h(t)*(R_a+R_b)= h(t) * \delta(t) = h(t)$

The temp variable is $R_a + R_b$, the sum of the autocorrelations.

Now is necessary to remember that Matlab starts counting from 1. Then, the autocorrelation of these sequences will result in a vector of length 15, where the first element will correspond to the element of index -7 of your autocorrelation. So, to perform the convolution right, you need to bring the element that is in the position eight to the first position. That's why the line temp(length(Ga):end) inside the conv function. Doing this, you can guarantee the equality $h(t) * \delta(t) = h(t)$

Then, you just need to normalize the output from the convolution, and you will have your channel response.

I didn't use noise, but I think that it is easy to implement this now.

Let me know if it helps and if you have any more doubts.