Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Matlab for the Gaussian Window

In matlab, w = gausswin(M,alpha) returns a length $ M$ window with parameter $ \texttt{alpha} \isdeftext 1/\tilde{\sigma}$ where $ \tilde{\sigma}\isdeftext \sigma/((M-1)/2)$ is defined, as in Harris [101], so that the window shape is invariant with respect to window length $ M$ :

function [w] = gausswin(M,alpha)
n = -(M-1)/2 : (M-1)/2;
w = exp((-1/2) * (alpha * n/((M-1)/2)) .^ 2)';

An implementation in terms of unnormalized standard deviation (sigma in samples) is as follows:

function [w] = gaussianwin(M,sigma)
n= -(M-1)/2 : (M-1)/2;
w = exp(-n .* n / (2 * sigma * sigma))';
In this case, sigma would normally be specified as a fraction of the window length $ M$ (sigma = M/8 in the sample below).

Note that, on a dB scale, Gaussians are quadratic. This means that parabolic interpolation of a sampled Gaussian transform is exact. This can be a useful fact to remember when estimating sinusoidal peak frequencies in spectra. For example, one suggested implication is that, for typical windows, quadratic interpolation of spectral peaks may be more accurate on a log-magnitude scale (e.g., dB) than on a linear magnitude scale (this has been observed empirically for a variety of cases).

Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work]  [Order a printed hardcopy]  [Comment on this page via email]
[Watch the Video]  [Work some Exercises]  [Examination]  
``Spectral Audio Signal Processing'', by Julius O. Smith III, W3K Publishing, 2011, ISBN 978-0-9745607-3-1.
Copyright © 2015-02-01 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University