Accelerating the pace of engineering and science

triang

Triangular window

w = triang(L)

Description

w = triang(L) returns an L-point triangular window in the column vector, w.

See Definitions for the equations that define the triangular window. 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. For L odd, the center L-2 points of triang(L-2) are equivalent to bartlett(L).

Examples

expand all

Triangular Window

Create a 200-point triangular window. Display the result using wvtool.

```L = 200;
w = triang(L);
wvtool(w)
```

Definitions

The coefficients of a triangular window are the following.

For L odd:

$w\left(n\right)=\left\{\begin{array}{ll}\frac{2n}{L+1}\hfill & 1\le n\le \left(L+1\right)/2\hfill \\ 2-\frac{2n}{L+1}\hfill & \left(L+1\right)/2+1\le n\le L\hfill \end{array}$

For L even:

$w\left(n\right)=\left\{\begin{array}{ll}\frac{\left(2n-1\right)}{L}\hfill & 1\le n\le L/2\hfill \\ 2-\frac{\left(2n-1\right)}{L}\hfill & L/2+1\le n\le L\hfill \end{array}$

References

[1] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1999.