File Exchange

image thumbnail

Replacement Window Functions

version 1.7.0.0 (2.89 KB) by Jim
Uncommonly Well-Behaved Implementations of Seven Common Window Functions

6 Downloads

Updated 15 Jul 2015

View License

Posted windows:
Hann
Hamming
Blackman
Blackman-Harris
Nuttall
Flat-Top
Kaiser

Most implementations of these seven windows, including most found in toolboxes and function libraries, are oddly behaved due to injudicious sampling of the underlying continuous-time functions. The posted versions are well-behaved and true, owing to careful, methodical sampling of those functions.

All the posted windows' mainlobe widths (in frequency units) go like 1/N, where N is the number of samples. Most other versions' mainlobes go like 1/(N-1), becoming excessively broad as length decreases, due to overly sparse sampling. A Boxcar window nicely illustrates the right behavior. It’s impossible to missample a Boxcar window, and its mainlobe goes exactly like 1/N.

The S/N loss (squared mean divided by mean square) of each posted window equals that of its underlying continuous-time function and is independent of window length. With most other versions, S/N loss worsens as length shortens, due to the same injudicious sampling responsible for the excess mainlobe width.

Conceptually, a windowed span of data is a span that's given nonzero weight. If a discrete-time window starts or ends with zero, it’s really a shorter window than its length suggests. Most implementations of the Hann and Blackman windows start and end with zero. They return windows of length N-2 in vectors of length N. None of the posted windows has this quirk.

The Kaiser window is naturally symmetric and non-periodic. The other six posted windows are naturally both symmetric and periodic. There’s no conflict between these properties and no need to select one or the other as some implementations require.

The Kaiser window's signature property is that it comes close to maximizing the mainlobe-to-sidelobe energy ratio. At long length and typical beta values, it's within a small fraction of a dB of this goal. As length shortens, however, most implementations run astray. For example, with beta = 7 at lengths 35, 25, and 20, the most common Kaiser implementation gives energy ratios that are 1 dB, 2 dB, and 3.2 dB short of the maximum, respectively. For the same lengths and mainlobe widths, the posted version’s energy ratios are only 0.04 dB, 0.11 dB, and 0.25 dB from the max -- truer to the intended behavior. This is entirely due to refined sampling. The Bessel function being sampled is unchanged.

The excellent behavior of the posted windows comes at no cost in complexity or speed. The functional forms are standard heritage. The number of function evaluations is half that of most versions, as allowed by symmetry.

The picture is a 60-point Kaiser window with beta = 5.44.

Cite As

Jim (2020). Replacement Window Functions (https://www.mathworks.com/matlabcentral/fileexchange/46731-replacement-window-functions), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

Updates

1.7.0.0

Revised summary and description.

1.6.0.0

The code now exploits symmetry for extra speed (half the ops). Revised description.

1.5.0.0

Fixed picture problem.

1.4.0.0

Attempts to update the picture failed, left a note in the text until the issue is resolved.

1.3.0.0

Revised picture, description, and summary.

1.2.0.0

Revised summary.

1.1.0.0

Revised summary.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux