Accelerating the pace of engineering and science

hann

Hann (Hanning) window

Syntax

w = hann(L)
w = hann(L,'sflag')

Description

w = hann(L) returns an L-point symmetric Hann window in the column vector w. L must be a positive integer. The coefficients of a Hann window are computed from the following equation.

$w\left(n\right)=\begin{array}{cc}0.5\left(1-\mathrm{cos}\left(2\pi \frac{n}{N}\right)\right),& 0\le n\le N\end{array}$

The window length is $L=N+1$.

w = hann(L,'sflag') returns an L-point Hann window using the window sampling specified by 'sflag', which can be either 'periodic' or 'symmetric' (the default). The 'periodic' flag is useful for DFT/FFT purposes, such as in spectral analysis. The DFT/FFT contains an implicit periodic extension and the periodic flag enables a signal windowed with a periodic window to have perfect periodic extension. When 'periodic' is specified, hann computes a length L+1 window and returns the first L points. When using windows for filter design, the 'symmetric' flag should be used.

 Note   If you specify a one-point window (L=1), the value 1 is returned.

Examples

expand all

Hann Window

Create a 64-point Hann window. Display the result using wvtool.

```L = 64;
wvtool(hann(L))
```

References

[1] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1999, p. 468.