# Wave Walker DSP

## DSP Algorithms for RF Systems

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

#### 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) where is the window length. The second form of the Bartlett window is from NumPy’s function

(2) where . The weights can also be generated using the following python code:

import numpy as npdef 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.

#### 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.