Hanning & Hamming Windows in MATLAB: Why the Discrepancy?

In summary, the conversation discusses the Hanning and Hamming windows and their definitions in MATLAB. The results of MATLAB functions do not match with the formulas, but the issue can be resolved by adjusting the denominator in the formula. The provided link may offer further explanation.
  • #1
truva
18
1
Hi all

As far as I know Hanning window is defined as the following:
.5+.5*cos(2*pi*n/N) and n is between [-(N-1)/2,(N-1)/2] here N is odd number.

MATLAB functions "hanning" with symetric or periodic options or "hann" do not match with the results of the above formula. There is always a slight annoying difference !

Do you know the problem?

(Same thing for Hamming window)
 
Physics news on Phys.org
  • #3
As I understand the book is wrong (Notes On Digital Signal Processing by C. Britton Rorabaugh). If I replace the N by (N-1) in the denumerator of the formulation which is 5+.5*cos(2*pi*n/(N-1)), the results coincide exactly with that of MATLAB.

Thank you for the link.
 

1. What are Hanning and Hamming windows in MATLAB?

Hanning and Hamming windows are two types of windows used in signal processing with MATLAB. They are used to modify a signal by multiplying it with a window function, which helps to reduce the effects of spectral leakage and improve the accuracy of frequency analysis.

2. What is the difference between Hanning and Hamming windows?

The main difference between Hanning and Hamming windows is in the shape of their window functions. Hanning windows have a raised cosine shape, while Hamming windows have a more rectangular shape. This results in different levels of attenuation at the edges of the window and can affect the frequency response of the signal.

3. Why is there a discrepancy between Hanning and Hamming windows in MATLAB?

The discrepancy between Hanning and Hamming windows in MATLAB is due to the different ways in which they are defined mathematically. Hanning windows are defined as a raised cosine function, while Hamming windows are defined as a cosine function multiplied by a constant. This leads to differences in the amplitude and frequency response of the windows.

4. Which window should I use in MATLAB - Hanning or Hamming?

The choice of window depends on the specific needs of your signal processing application. In general, Hanning windows are better at reducing spectral leakage, while Hamming windows have a higher dynamic range. It is recommended to experiment with both windows and choose the one that best suits your needs.

5. Can I create custom Hanning and Hamming windows in MATLAB?

Yes, MATLAB allows you to create custom Hanning and Hamming windows by specifying the window length and any desired parameters. This can be done using the hann and hamming functions. You can also use the window function to create any other type of window in MATLAB.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
742
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
565
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
16
Views
13K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top