MATLAB Answers


Are MATLAB's window functions incorrect (starting at n = 1 instead of n = 0)?

Asked by Miles Henrichs on 20 Mar 2019 at 3:32
Latest activity Answered by Jan
on 20 Mar 2019 at 13:16
According to Wikipedia's page on window functions, the first value of most of these functions should be 0. For example, triangular windows are defined for 0 <= n <= N - 1.
In contrast, MATLAB's windowing functions (I'll use triang() as an example) define the window for 1 <= n <= N.
triangular_window = triang(10); % first value is 0.1, not 0
Is this incorrect? If not, why?


I suspect this has something to do with Matlab being a 1 index language, instead of 0 index (which is the majority of the programming languages).
Have a look at all the values. Compare with triang(9). Think about what contribution first and last-element with zero in them would contribute to in filtering and whether you need to drag those through the calculations...

Sign in to comment.




1 Answer

Answer by Jan
on 20 Mar 2019 at 13:16

The documentation is clear in this point:
The triangular window is very similar to a Bartlett window. The Bartlett window always ends with zeros at samples 1 and L, while the triangular window is nonzero at those points.
w(n) = (2*n-1) / L for 1<=n<=L/2
Does this clarify your question?


Sign in to comment.