Matched Filter Using Octave GNU Tool

1. Abbreviation

SNR – signal to noise ratio (S/N = Signal/Noise)
δ(t) – Dirac delta function: t=0 δ(0)= +∞; t≠0 δ(t)=0
PSK – Phase Shift Keying digital modulation
FSK – Frequency Shift Keying digital modulation
MLS – maximum length sequence
FIR – Finite Impulse Response
IIR – Infinite Impulse Response

2. Introduction

Matched filter is designed to recognize a signal of a known shape with additive noise. The algorithm does not reproduce the original signal form from the noise. If a sample signal is detected then the filter should react by increasing the output level (by maximizing the SNR ratio). In the ideal case the matched filter generates a pulse, and then the threshold device decides whether to receive the signal.
Matched filter is mainly used in radar and communication systems. More information about this can be found in [1], [2], [3].
Here I write without proof the basic information needed to implement the matched filter.
  1. Matched filter has a finite impulse response and therefore is implemented digitally with FIR filter
  2. The matched filter impulse response has:
    where s(t) – signal sample, i.e. the signal that needs to be recognized by matched filter
    Tsig – signal time length
    Thus, the impulse response of the matched filter is a mirror image of the signal itself.
    The correlation function is calculated at the filter output. This is easy to prove. Let the signal s(t) come to the filter input then calculating the convolution:
    – correlation function
    The maximum output value of the filter is reached at time t = Ts and the value is proportional to the energy of the signal sample:
  3. By calculating the Fourier transform of h(t), it is easy to show that the spectral characteristic of the matched filter has:
    Matched_formula4_1 – complex conjugate of the signal sample spectrum
    In the case of matched filtering, the frequency components of the signal are added coherently, and the frequency components of the noise are incoherent, which provides the maximum SNR.
It is important to choose the correct signal sample. I have already mentioned that the matched filter should generate a narrow pulse at the output after receiving the expected signal. Ideally the autocorrelation function of the signal sample should be Dirac delta function:
and take values:
R(τ) = 0 for τ ≠ 0
R(0) = +∞ for τ = 0 (6)
These conditions (5), (6) are in reality unreachable. Nevertheless it is possible to formulate the requirements for the signal. The signal shall be broadband or often said to be noise-like (pseudorandom) because white Gaussian noise has the same correlation function (5).
To evaluate the bandwidth, the concept of a signal base is introduced:
where Fband – signal band width, Tsig – signal duration
Matched filter signal shall satisfy the condition:
Here are some examples of the signals used for matched filter:
  • Barker code
  • Maximum length sequence (MLS)
  • Gold sequence
  • Kasami sequence
  • Walsh functions. These functions are orthogonal and are used to separate communication channels. Autocorrelation and cross-correlation of these functions are not well suited for matched filter, but they are often used in communication systems
Next, I’ll give you some examples of matched filters.


3. Matched filter for chirp signal

Consider an example of matched filter for chirp signal:
where 0 ≤ t ≤ Tsig
See the Figure 3-1:

                                                       Figure 3-1: Chirp Signal


Then using (1) the Matched Filter Impulse Response has:
where 0 ≤ t ≤ Tsig
See the Figure 3-2:

                                               Figure 3-2: Chirp Matched Filter Impulse Resonse


Now we send the signal (9) to the input of this filter and get the filter response, as shown in Figure 3-3. After receiving the chirp signal, the matched filter generates a short pulse. There are still lateral local maxima, the level of which is significantly lower than the main maximum.

                                        Figure 3-3: Matched Filter Response on the Chirp Signal


4. Matched filter for Phase Shift Keying (PSK) with Barker Code

Consider a simple version of Phase Shift Keying (PSK) with only two phases 0 and π.
Note: Logical 0 can be defined as -1.
We use the Barker Code with a length of 11:
BarkerCode_11 = [1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1];
This sequence has a good autocorrelation function with a narrow peak. See the Figure 4-1


                                            Figure 4-1: Autocorrelation function of the Barker code with the length 11


Now let’s build a PSK with Barker code. See the Figure 4-2:

                                               Figure 4-2: PSK with the Barker code with the length 11


Using (1) the matched filter pulse response has the form shown in Figure 4-3

                                       Figure 4-3: Matched Filter Impulse Response of the PSK with the Barker code


Then the reaction of the matched filter to this PSK signal sample shown in the Figure is 4-4:


                                          Figure 4-4: Matched Filter Response on the PSK with the Barker code


The PSK signal can be considered as a packet of radio pulses with phases 0 and π. Then we can build a matched filter for only one radio pulse and then use the tdelay time delay line for each subsequent radio pulse with a coefficient bi : +1 for the phase 0 and -1 for the phase π. See the Figure 4-5

                               Figure 4-5: PSK Matched Filter Using only One Radio Impulse S*one(jω)
                                                   where t_delay – one radio impulse time length


5. Matched filter for Maximum Length Sequence (MLS)

Maximum Length Sequence (MLS) is pseudorandom binary sequence which is generated using linear feedback shift registers. MLS has a periodic sequence with period N:
where k – bits number of the shift register
The shift register and its feedbacks can be determined using a polynomial. For example, the polynomial (13) corresponds to the shift register shown in Figure 5-1.


The polynomial can still be written as a binary number. In our example: 10000011, where bits: 7, 1, 0 have the values 1 (feedbacks are active) and all other bits have the values 0.


                                        Figure 5-1: MLS: Feedback Shift Register


In the example, an MLS length is
and the register initial (start) value must be non-zero.
Now let’s build a Matched Filter for MLS using (1). The signal at the filter output after receiving the MLS is shown in Figure 5-2


                                            Figure 5-2: Matched Filter Response on the MLS 10000011 sequence


  • The lateral local maxima of the MLS autocorrelation function do not exceed the value:
    In our example:
  • There are many polynomials of different lengths that you can use to form the MLS sequence that suits you. The table of polynomials is easy to find in the special literature. See the few polynomials in the Table 5-1:


                          Table 5-1: MLS polynomials


  • MLS is also used for PSK or FSK modulation. In this case, you can also get an effective matched filter

6. Realization of the matched filter

Matched filter has a finite impulse response and therefore is implemented in digital technic using FIR filter. See the article: “FIR Filter Implementation Using Octave GNU Tool and C Language“


7. Download the matched_filter.m

Octave GNU file matched_filter.m
You can see in the file all calculations and all graphics for the article.


8. Literature / References

[1] John G. Proakis, Masoud Salehi, “Digital Communications”, Fifth Edition, MC Graw-Hill, Higher Education, ISBN 978–0–07–295716–7
[2] L.Rabiner, B.Gold “Theory and application of digital signal processing“, Prentice-Hall, Ing Englewood Cliffs, New Jercy 1975
[3] Allan V. Oppenheim “Applications of Digital Signal Processing“, Massachusetts Institute of Technology Cambridge, Prentice Hall, Inc., Englewood Cliffs, New Jersey, 1978
[4] I. S. Gonorovsky “Radio engineering circuits and signals”, Moscow, “Radio and Communications”, 1986