# Windowing

Almost every application requires you to use finite length signals. This requires that continuous signals be truncated using a process called windowing.

The simplest window is a rectangular window. Because this window requires no special effort, it is commonly referred to as the no window option. Remember, however, that a window always affects a discrete signal and its spectrum. Let Xn be a digitized time-domain waveform that has a finite length of n. Wn is a window sequence of n points. The windowed output is calculated as follows:

yi = xi × wi

If X, Y, and W are the spectra of x, y, and w, respectively, the time-domain multiplication in the previous equation is equivalent to the frequency domain convolution shown as follows:

Yk = Xk θ Wk

Convolving with the window spectrum always distorts the original signal spectrum in some way. A window spectrum consists of a mainlobe and several sidelobes.

The mainlobe is the primary cause of lost frequency resolution. When two signal spectrum lines are too close to each other, they might fall in the width of the mainlobe, causing the output of the windowed signal spectrum to have only one spectrum line. Use a window with a narrower mainlobe to reduce the loss of frequency resolution. A rectangular window has the narrowest mainlobe, so it provides the best frequency resolution.

The sidelobes of a window function affect frequency leakage. A signal spectrum line leaks into the adjacent spectrum if the sidelobes are large. Once again, the leakage results from the convolution process. Select a window with smaller sidelobes to reduce spectral leakage. Unfortunately, a narrower mainlobe and smaller sidelobes are mutually exclusive. For this reason, selecting a window function is application dependent. The following figure shows an example of a windowed spectrum in the continuous case.

## Windowed Spectrum in the Continuous Case

The original signal spectrum in the preceding figure is convolved with the window spectrum, and the output is a smeared version of the original signal spectrum. In this figure, you can still see four distinctive peaks from the original signal; however, each peak is smeared, and the frequency leakage effect is clear.

Window definitions used in National Instruments analysis libraries are designed in such a way that the window operations in the time domain are equivalent to the operations of the same window in the frequency domain. To meet this requirement, the windows are not symmetrical in the time domain, that is

W0 ≠ WN – 1

where N is the window length.

However, the windows are usually symmetrical in the frequency domain. For example, the Hamming window definition uses the following formula:

(1)

Other manufacturers might use a slightly different definition, such as the following formula:

(2)

The difference between these definitions is small if N is large.

Equation (1) is not symmetrical in the time domain, but this equation ensures that the time domain windowing is equivalent to the frequency domain windowing. If you want to have a perfectly symmetrical sequence in the time domain, you must write your own windowing function using Equation (2).

The choice of a window depends on the application. For most applications, the Hamming or Hanning windows deliver good performance.