### Matlab for the Hamming Window

In Matlab or Octave, a length Hamming window is designed by the statement

w = hamming(M);which is equivalent to

w = .54 - .46*cos(2*pi*(0:M-1)'/(M-1));Note that

`M-1`is used in the denominator rather than

`M+1`as in the Hann window case. Since the Hamming window

*cannot*reach zero for any choice of samples of the defining raised cosine, it makes sense not to have

`M+1`here. Using

`M-1`(instead of

`M`) provides that the returned window is

*symmetric*, which is usually desired. However, we will learn later that there are times when

`M`is really needed in the denominator (such as when the window is being used successively over time in an

*overlap-add*scheme, in which case the sum of overlapping windows must be constant).

The `hamming` function in the Matlab 6.1 Signal Processing Tool
Box has an optional argument `'periodic'` which effectively
uses instead of . The default case is `'symmetric'`.
The following examples should help clarify the difference:

>> hamming(3) ans = 0.0800 1.0000 0.0800 >> hamming(3,'symmetric') ans = 0.0800 1.0000 0.0800 >> hamming(3,'periodic') ans = 0.0800 0.7700 0.7700 >> hamming(4) ans = 0.0800 0.7700 0.7700 0.0800

**Next Section:**

Summary of Generalized Hamming Windows

**Previous Section:**

Hamming Window