| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Signal Processing Toolbox |
| Contents | Index |
| Learn more about Signal Processing Toolbox |
| 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(7)
ans =
0
0.3333
0.6667
1.0000
0.6667
0.3333
0
triang(5)
ans =
0.3333
0.6667
1.0000
0.6667
0.3333
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)]
ans =
0.2857 0.1667
0.5714 0.5000
0.8571 0.8333
0.8571 0.8333
0.5714 0.5000
0.2857 0.1667
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
0,
, and
, where N is
the window length. One way to generate them is
ind = (0:n-1)'*2*pi/(n-1); w = A - B*cos(ind) + C*cos(2*ind);
where A, B, and C are constants you define. 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 Hamming and A = 0.5, B = 0.5 for Hann (C = 0 in both cases). The hamming and hann functions, respectively, compute these windows.
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.
The Blackman window is a popular three-term window, given by A = 0.42, B = 0.5, C = 0.08. The blackman function computes this window.
The Flat Top window is a five-term window and is used for calibration. It is given by A = 1, B = 1.93, C = 1.29, D =0.388, and E = 0.322.
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
rad/s, transition width
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.
![]() | Special Topics | Parametric Modeling | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |