Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books

Sponsor

Industry's highest performing at the lowest power DSPs now as low as $5.00*
Start development today!
*volume pricing for 10ku

Chapters

See Also

Embedded SystemsFPGAElectronics
Chapter Contents:

Search Spectral Audio Signal Processing

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Matlab for the Gaussian Window

In Matlab, w = gausswin(M,alpha) returns a length $ M$ window with parameter $ \texttt{alpha} = 1/\sigma$. It implements the definition in Harris [97]:

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

An implementation in terms of $ \sigma$ is as follows:

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

Note that, on a dB scale, the Gaussian is 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).


Previous: Gaussian Window and Transform
Next: Gaussian Window and Transform

Order a Hardcopy of Spectral Audio Signal Processing


About the Author: Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


 

Thomas wrote:

2/21/2011
 
Hi,

thank you very much for your material.

Shouldn't it be (M-1)/2 instead of (M/2) in
w = exp((-1/2) * (alpha * n/(M/2)) .^ 2)';
---> w = exp((-1/2) * (alpha * n/((M-1)/2)) .^ 2)';

In the sigma implementation, the term is completely missing. I think it should look like this:
w = exp(-(1/2) * (n / (sigma*((M-1)/2) )) .^ 2)';
 

JOS wrote:

2/21/2011
 
1. Yes - fixed in the source - thanks!

2. That would be fine. However, in looking at this again, I see that the Matlab (Harris) definition of alpha has been normalized by (M-1)/2 in order to keep the window shape invariant with respect to window length M. Therefore, I would leave the sigma implementation alone and document that the Harris version defines alpha = (M-1)/(2*sigma). In usage of the sigma implementation, one defines sigma as a fraction of the window length (M/8 in the example used in the figure on the next page). I find this more intuitive myself.

Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )