Search code examples
matlaboctave

MATLAB Hamming-window


I am using Hamming window using the first principle equation to produce a window of length 23. Below is the code that I am using:

>> M=23
>> w = .54 - .46*cos(pi*(0:M-1)'/M)
>> plot(w)

Why is the graph not displaying a popper Hamming window please? Attached are the equation I am using and the output for this code. Any kind of help would be highly appreciated.

enter image description here

enter image description here


Solution

  • The issue is that your n is going from 0 to M-1 not from -M to M

    Try this instead:

    M = 23
    w = .54 + .46*cos(pi*(-M:M)/M)
    plot(w)