Main Content

bartlett

Bartlett window

Description

w = bartlett(L) returns an L-point symmetric Bartlett window.

example

w = bartlett(L,typeName) specifies the option to return the window w with single or double precision.

Examples

collapse all

Create a 64-point Bartlett window. Display the result using wvtool.

L = 64;
bw = bartlett(L);
wvtool(bw)

Figure Window Visualization Tool contains 2 axes objects and other objects of type uimenu, uitoolbar, uipanel. Axes object 1 with title Time domain, xlabel Samples, ylabel Amplitude contains an object of type line. Axes object 2 with title Frequency domain, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Magnitude (dB) contains an object of type line.

Input Arguments

collapse all

Window length, specified as a positive integer.

Note

If you specify L as noninteger, the function rounds it to the nearest integer value.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Since R2024b

Output data type (class), specified as one of these:

  • "double" — Use this option to return a double-precision output w.

  • "single" — Use this option to return a single-precision output w.

Data Types: char | string

Output Arguments

collapse all

Bartlett window, returned as a column vector.

Algorithms

The following equation generates the coefficients of a Bartlett window:

w(n)={2nN,0nN2,22nN,N2nN.

The window length L=N+1.

The Bartlett window is very similar to a triangular window as returned by the triang function. However, the Bartlett window always has zeros at the first and last samples, while the triangular window is nonzero at those points. For odd values of L, the center L-2 points of bartlett(L) are equivalent to triang(L-2).

Note

If you specify a one-point window (L = 1), the value 1 is returned.

References

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a

expand all