Hanning & Hamming Windows in MATLAB: Why the Discrepancy?

  • Context: MATLAB 
  • Thread starter Thread starter truva
  • Start date Start date
  • Tags Tags
    Matlab Window
Click For Summary
SUMMARY

The discrepancy between the Hanning and Hamming windows in MATLAB and their theoretical definitions arises from the formula used. The Hanning window is defined as 0.5 + 0.5*cos(2*pi*n/N) for n in the range [-(N-1)/2, (N-1)/2], where N is an odd number. However, MATLAB's "hanning" and "hann" functions yield results that differ slightly from this formula. Adjusting the denominator to (N-1) resolves this discrepancy, aligning MATLAB's output with the theoretical expectations.

PREREQUISITES
  • Understanding of digital signal processing (DSP) concepts
  • Familiarity with MATLAB programming and its signal processing toolbox
  • Knowledge of window functions in signal analysis
  • Basic trigonometry and cosine functions
NEXT STEPS
  • Explore the MATLAB documentation for the "hanning" and "hann" functions
  • Research the mathematical derivation of window functions in DSP
  • Learn about the implications of windowing on frequency analysis
  • Investigate alternative window functions and their applications in MATLAB
USEFUL FOR

Digital signal processing students, MATLAB users, and engineers working on signal analysis and filtering techniques.

truva
Messages
18
Reaction score
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
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 16 ·
Replies
16
Views
15K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K