The Hann window is a commonly used window in signal processing. It is used to improve the frequency domain analysis of a signal by tapering the edges of the signal toward zero, which reduces the frequency leakage caused by the sharp drop-offs at the edges.
Here are a few different ways to implement the Hann window function in MATLAB:
hann()
function built into MATLAB:main.m116 chars7 lines
w(n) = 0.5 * (1 - cos(2*pi*n/(N-1)))
, where n
is the index of the sample in the window and N
is the total number of samples in the window:main.m162 chars9 lines
window()
function in MATLAB with the 'hann'
argument:main.m126 chars7 lines
All of these methods will produce the same output: a Hann window with N
points, which can be applied to a signal using element-wise multiplication.
gistlibby LogSnag