Wave Walker DSP

DSP Algorithms for RF Systems

Most Popular

Buy the Book!

DSP for Beginners: Simple Explanations for Complex Numbers! The second edition includes a new chapter on complex sinusoids.

Bartlett (Triangular) Window Analysis With Python Code
July 1, 2023

Table of Contents

Introduction

An introduction to the Bartlett window: the impulse response is defined and a brief analysis of the frequency response as compared against the rectangular window. The Bartlett may also be referred to as the “triangular” window due to the shape in the time domain.

More blogs!

Bartlett (Triangular) Window Design Equation

The Bartlett window, or triangular window, is a useful tool in spectral analysis. Applying a window function reduces the sidelobes of the spectral response, reducing the energy from higher frequencies that is aliased into the lower frequencies.

The Bartlett window has two forms, both of which produce the equivalent window. The first is [Oppenheim1999, p.468],

(1)   \begin{equation*}w[n] = \begin{cases}\frac{2n}{N}, & 0 \le n \le N/2, \\2-\frac{2n}{N}, & N/2 < n \le N, \\0, & \text{otherwise,}\end{cases}\end{equation*}

where N+1 is the window length. The second form of the Bartlett window is from NumPy’s function

(2)   \begin{equation*}w[n] = \frac{2}{N-1}\left( \frac{N-1}{2} - \left| n - \frac{N-1}{2}  \right|\right),\end{equation*}

where 0 \le n \le N-1. The weights can also be generated using the following python code:

import numpy as np
def
createBartlett ( N ):
    n = np.arange(0,(N/2))
    leftSide = n/((N-1)/2)
    if (np.mod(N,2) == 0): 
        rightSide = leftSide[::-1]
    else:
        rightSide = leftSide[0:-1][::-1]
    window = np.concatenate((leftSide,rightSide))
    return window

Impulse Response

The impulse response for the Bartlett window with length N=31 is given in Figure 1 and length N=32 in Figure 2.

Figure 1: The Bartlett Window impulse response with length N=31.
Figure 1: The Bartlett Window impulse response with length N=31.
Figure 2: The Bartlett Window impulse response with length N=32.
Figure 2: The Bartlett Window impulse response with length N=32.

Frequency Domain Analysis

Figures 3 and 4 give the frequency response of the Bartlett window for lengths N=31 and N=32. The rectangular window is used as a comparison because it is the same as not using any windowing function.

The Bartlett window improves the sidelobes by more than 15 dB in Figure 3 and more than 20 dB in Figure 4.

The Bartlett window has two downsides:

  1. Additional computations to apply the window,
  2. Increases the bandwidth of the main lobe.

However the improvement in sidelobe attenuation is well worth the cost and produces an overall superior spectral response.

Figure 3: The Bartlett Window frequency response with length N=31.
Figure 3: The Bartlett Window frequency response with length N=31.
Figure 4: The Bartlett Window frequency response with length N=32.
Figure 4: The Bartlett Window frequency response with length N=32.

Conclusion

The Bartlett window improves upon the frequency response of the rectangular window by reducing the sidelobes at the cost of increasing the bandwidth of the main lobe and additional computations needed to apply the window. However, the Bartlett window creates a better spectral response than the rectangular window, which is equivalent to applying no window at all.

More blogs!

God, the Lord, is my strength; he makes my feet like the deer’s; he makes me tread on my high places. Habakkuk 3:19

Leave a Reply

This website participates in the Amazon Associates program. As an Amazon Associate I earn from qualifying purchases.