Main Content

sigwin.hamming Class

Namespace: sigwin

Construct Hamming window object

Description

Note

The use of sigwin.hamming is not recommended. Use hamming instead.

sigwin.hamming creates a handle to a Hamming window object for use in spectral analysis and FIR filtering by the window method. Object methods enable workspace import and ASCII file export of the window values.

The following equation defines the Hamming window of length N:

w(n)=0.540.46cos2πnN1,0nM1

where M is N/2 for N even and (N+1)/2 for N odd.

The second half of the symmetric Hamming window MnN1 is obtained by flipping the first half around the midpoint. The symmetric option is the preferred method when using a Hamming window in FIR filter design.

The periodic Hamming window is constructed by extending the desired window length by one sample, constructing a symmetric window, and removing the last sample. The periodic version is the preferred method when using a Hamming window in spectral analysis because the discrete Fourier transform assumes periodic extension of the input vector.

Construction

H = sigwin.hamming returns a symmetric Hamming window object H of length 64.

H = sigwin.hamming(Length) returns a symmetric Hamming window object with length Length. Length must be a positive integer. Entering a positive noninteger value for Length rounds the length to the nearest integer. Entering a 1 for Length results in a window with a single value of 1.

H = sigwin.hamming(Length,SamplingFlag) returns a Hamming window with sampling Sampling_Flag. The SamplingFlag can be either 'symmetric' or 'periodic'.

Properties

Length

Hamming window length. The window length must be a positive integer. Entering a positive noninteger value for Length rounds the length to the nearest integer. Entering a 1 for Length results in a window with a single value of 1.

SamplingFlag

'symmetric' is the default and forces exact symmetry between the first and second halves of the Hamming window. A symmetric window is preferred in FIR filter design by the window method.

'periodic' designs a symmetric Hamming window of length Length+1 and truncates the window to length Length. This design is preferred in spectral analysis where the window is treated as one period of a Length-point periodic sequence.

Methods

generateGenerates Hamming window
infoDisplay information about Hamming window object
winwriteSave Hamming window in ASCII file

Copy Semantics

Handle. To learn how copy semantics affect your use of the class, see Copying Objects in the MATLAB® Programming Fundamentals documentation.

Examples

collapse all

Generate two Hamming windows:

  • The first window has N = 64 and is symmetric.

  • The second window has N = 63 and is periodic.

Display the two windows.

Hs = sigwin.hamming(64,'symmetric');
Hp = sigwin.hamming(63,'periodic')
Hp = 
            Name: 'Hamming'
    SamplingFlag: 'periodic'
          Length: 63

wvt = wvtool(Hs,Hp);
legend(wvt.CurrentAxes,'Symmetric','Periodic')

Generate a symmetric Hamming window with N = 16. Return the window values as a column vector. Show information about the window object. Display the window.

H = sigwin.hamming(16);

win = generate(H)
win = 16×1

    0.0800
    0.1198
    0.2322
    0.3979
    0.5881
    0.7700
    0.9121
    0.9899
    0.9899
    0.9121
      ⋮

wininfo = info(H)
wininfo = 4x26 char array
    'Hamming Window            '
    '--------------            '
    'Length         : 16       '
    'Sampling Flag  : symmetric'

wvtool(H)

References

Oppenheim, Alan V., and Ronald W. Schafer. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1989.