## Documentation Center |

On this page… |
---|

In both digital filter design and spectral estimation, the choice of a windowing function can play an important role in determining the quality of overall results. The main role of the window is to damp out the effects of the Gibbs phenomenon that results from truncation of an infinite series.

Window | Function |
---|---|

Bartlett-Hann window | |

Bartlett window | |

Blackman window | |

Blackman-Harris window | |

Bohman window | |

Chebyshev window | |

Flat Top window | |

Gaussian window | |

Hamming window | |

Hann window | |

Kaiser window | |

Nuttall's Blackman-Harris window | |

Parzen (de la Valle-Poussin) window | |

Rectangular window | |

Tapered cosine window | |

Triangular window |

Two graphical user interface tools are provided for working with windows in the Signal Processing Toolbox™ product:

Refer to the reference pages for these tools for detailed information.

The basic window is the *rectangular window*, a vector of ones
of the appropriate length. A rectangular window of length 50 is

n = 50; w = rectwin(n);

This toolbox stores windows in column vectors by convention, so an equivalent expression is

w = ones(50,1);

To use the Window Design and Analysis Tool to create this window, type

wintool

`wintool` opens with a
default Hamming window. In the Current Window Information panel, set **Type = Rectangular** and **Length = 50** and then press **Apply**.

The *Bartlett* (or
triangular) *window* is the convolution of two
rectangular windows. The functions `bartlett` and `triang` compute similar triangular windows,
with three important differences. The `bartlett` function
always returns a window with two zeros on the ends of the sequence,
so that for `n` odd, the center section of `bartlett(n+2)` is
equivalent to `triang(n)`:

Bartlett = bartlett(7); isequal(Bartlett(2:end-1),triang(5)) % Returns a 1

For `n` even, `bartlett` is
still the convolution of two rectangular sequences. There is no standard
definition for the triangular window for `n` even;
the slopes of the line segments of the `triang` result
are slightly steeper than those of `bartlett` in
this case:

w = bartlett(8); [w(2:7) triang(6)]

You can see the difference between odd and even Bartlett windows in WinTool.

The final difference between the Bartlett and triangular windows
is evident in the Fourier transforms of these functions. The Fourier
transform of a Bartlett window is negative for `n` even.
The Fourier transform of a triangular window, however, is always nonnegative.

The following figure, which is a zoomed version
of the Frequency domain plot of 8-point Bartlett and Triangular windows
with the *y*-axis set to Zerophase, illustrates
this difference.

This difference can be important when choosing a window for some spectral estimation techniques, such as the Blackman-Tukey method. Blackman-Tukey forms the spectral estimate by calculating the Fourier transform of the autocorrelation sequence. The resulting estimate might be negative at some frequencies if the window's Fourier transform is negative (see Kay [1], pg. 80).

Blackman, flat top, Hamming, Hann, and rectangular windows
are all special cases of the *generalized cosine window*.
These windows are combinations of sinusoidal sequences with frequencies
that are multiples of
, where *N* is
the window length. One special case is the Blackman window:

N = 128; A = 0.42; B = 0.5; C = 0.08; ind = (0:N-1)'*2*pi/(N-1); w = A - B*cos(ind) + C*cos(2*ind);

Changing the values of the constants `A`, `B`,
and `C` in the previous expression generates different
generalized cosine windows like the Hamming and Hann windows. Adding
additional cosine terms of higher frequency generates the flat top
window. The concept behind these windows is that by summing the individual
terms to form the window, the low frequency peaks in the frequency
domain combine in such a way as to decrease sidelobe height. This
has the side effect of increasing the mainlobe width.

The Hamming and Hann windows are two-term generalized cosine
windows, given by `A` = `0.54`, `B` = `0.46` for the Hamming
and `A` = `0.5`, `B` = `0.5` for the Hann.

Note that the definition of the generalized cosine window shown
in the earlier MATLAB^{®} code yields zeros at samples 1 and `n` for `A` = `0.5` and `B` = `0.5`.

This WinTool compares Blackman, Hamming, Hann, and Flat Top windows.

The *Kaiser window* is
an approximation to the prolate-spheroidal window, for which the ratio of the
mainlobe energy to the sidelobe energy is maximized. For a Kaiser
window of a particular length, the parameter β
controls the sidelobe height. For a given β, the sidelobe height
is fixed with respect to window length. The statement `kaiser``(n,beta)` computes
a length `n` Kaiser window with
parameter `beta`.

Examples
of Kaiser windows with length 50 and `beta` parameters
of 1, 4, and 9 are shown in this `wintool` example.

To create these Kaiser windows using the MATLAB command line,

n = 50; w1 = kaiser(n,1); w2 = kaiser(n,4); w3 = kaiser(n,9); [W1,f] = freqz(w1/sum(w1),1,512,2); [W2,f] = freqz(w2/sum(w2),1,512,2); [W3,f] = freqz(w3/sum(w3),1,512,2); plot(f,20*log10(abs([W1 W2 W3]))); grid; legend('beta = 1','beta = 4','beta = 9',3)

As β increases, the sidelobe height decreases and the mainlobe width increases. This wintool shows how the sidelobe height stays the same for a fixed β parameter as the length is varied.

To create these Kaiser windows using the MATLAB command line:

w1 = kaiser(50,4); w2 = kaiser(20,4); w3 = kaiser(101,4); [W1,f] = freqz(w1/sum(w1),1,512,2); [W2,f] = freqz(w2/sum(w2),1,512,2); [W3,f] = freqz(w3/sum(w3),1,512,2); plot(f,20*log10(abs([W1 W2 W3]))); grid; legend('length = 50','length = 20','length = 101')

There
are two design formulas that can help you design FIR filters to meet
a set of filter specifications using a Kaiser window. To achieve a
sidelobe height of -α dB, the `beta` parameter
is

For a transition width of Δω rad/s, use the length

Filters designed using these heuristics will meet the specifications approximately, but you should verify this. To design a lowpass filter with cutoff frequency 0.5π rad/s, transition width 0.2π rad/s, and 40 dB of attenuation in the stopband, try

[n,wn,beta] = kaiserord([0.4 0.6]*pi,[1 0],[0.01 0.01],2*pi); h = fir1(n,wn,kaiser(n+1,beta),'noscale');

The `kaiserord` function
estimates the filter order, cutoff frequency, and Kaiser window beta
parameter needed to meet a given set of frequency domain specifications.

The ripple in the passband is roughly the same as the ripple in the stopband. As you can see from the frequency response, this filter nearly meets the specifications:

fvtool(h,1);

The Chebyshev window minimizes the mainlobe width, given a particular sidelobe height. It is characterized by an equiripple behavior, that is, its sidelobes all have the same height.

As shown in the Time Domain plot, the Chebyshev window has large spikes at its outer samples.

For a detailed discussion of the characteristics and applications of the various window types, see Oppenheim and Schafer [3], pgs. 444-462, and Parks and Burrus [4], pgs. 71-73.

Was this topic helpful?