HANNING

Purpose:

Multiplies a series with a Hanning window.

Syntax:

HANNING(series, ampflag, "sym")

series

-

A series or array.

ampflag

-

Optional. An integer, the amplitude correction flag:

0

:

do not correct amplitude (default)

1

:

correct amplitude

2

:

correct RMS amplitude

3

:

correct mean squared amplitude

"sym"

-

Optional. A string, the symmetry flag:

"symmetric"

:

Starting and ending points are equal, but leading and trailing zeros are removed (default).

"periodic"

:

Periodically extended window where the leading zero is preserved. Conforms to the ISO standard.

"direct"

:

Starting and ending points are both zero

"iso"

:

Same as "periodic".

Alternate Syntax:

HANNING(N, ampflag, "sym")

N

-

An integer, the window length.

ampflag

-

Optional. An integer, the amplitude correction flag:

0

:

do not correct amplitude (default)

1

:

correct amplitude

2

:

correct RMS amplitude

3

:

correct mean squared amplitude

"sym"

-

Optional. A string, the symmetry flag:

"symmetric"

:

Starting and ending points are equal, but leading and trailing zeros are removed (default).

"periodic"

:

Periodically extended window where the leading zero is preserved. Conforms to the ISO standard.

"direct"

:

Starting and ending points are both zero

"iso"

:

Same as "periodic".

Returns:

A series or array.

Example:

W1: gsin(1000, .001, 45)

W2: spectrum(hanning(W1))

W3: spectrum(hanning(W1, 1))

 

The MAX of W2 == 0.5005 and the MAX of W3 == 1.0. The amplitude of the spectrum in W3 has been corrected to take into account amplitude effects of the symmetric Hanning window. The symmetric window follows the form:

 

 

where n is the nth point (1 <= n <= N) and N = L+1 where L is the number of points to generate. The leading zero is removed.

Example:

W4: hanning(1000, "periodic")

 

Creates a 1000 point periodic Hanning window that conforms to the ISO 18431-1 standard.

 

 

where n is the nth point (1 <= n <= N) and N = L where L is the number of points to generate. The leading zero is preserved.

Example:

W1: hanning(1000, "direct")

 

Creates a 1000 point direct Hanning window by the formula:

 

 

where n is the nth point (1 <= n <= N) and N is the number of points to generate. The leading and trailing zeros are preserved.

 

Remarks:

If ampflag == 1, the correction factor is the mean of the spectral window. This assures that the spectrum of a sinusoid of amplitude A has a peak of A.

 

If ampflag == 2, the correction is applied as follows:

 

 w = hanning(s) * rms(s) / rms(hanning(s))

 

This assures that:

 

sqrt(area(psd(w))) == rms(s) approximately

 

If ampflag == 3, the correction is applied as follows:

 

w = winfun(s) / sqrt(mean(win * win) 

 

where win is the windowing function.

 

The "sym" flag controls the window symmetry as follows:

 

"Symmetric" sets the last point to be the same value as the first point. For an N point symmetric window, a N+1 point periodic window is effectively created and the leading zero is removed.

 

"Periodic" or "iso" creates a periodic window function useful in spectrum analysis applications where the starting zero is preserved and the trailing zero is removed. "Periodic" or "iso" conforms to the ISO 18431-1 standard for windowing functions.

 

The Hamming, Hanning, Flattop and Blackman windows are part of the family of cosine window functions. The ISO 18431-1 standard periodic form of these windowing functions are defined by:

 

 

where K is the number of window coefficients and N is the length of the window. The direct form of the window can be constructed by setting N to N-1. The symmetric Hanning window is formed by creating a N+1 periodic window and removing the leading zero.

 

For the default Hanning window:

 

 

See GHANNING to generate a Hanning window.

 

The Hanning window is sometimes referred to as a Hann window.

See Also:

BLACKMAN

BLACKMANHARRIS

CHEBWIN

FLATTOP

GHANNING

HAMMING

KAISER

PSD

SPECTRUM

TAYLORWIN

WINFUNC