Investment Studio > Expressions > Functions > DSP > TRIANGLE

Vector form: float array[1][length] triangle(integer length)

Returns a row vector (one row, length columns) containing the values of a triangular window starting at position 1 and ending at position length > 1.

Scalar form: float triangle(integer length, integer position)

Returns the value in position >= 1 of a triangular window starting at position 1 and ending at position length > 1.

The triangular window function (also referred to as the Bartlett function) is defined as

m = length -1

n = position - 1

  ì

2 * n / m,

 

0 <= n <= m/2

triangle[n] =

í

2 - 2 * n / m,

 

m/2 < n <= m

  î

0,

 

otherwise

Example

The graph source

=triangle(100, x)

can be used to create the following graph:

See also blackman, convolve, hamming, hanning, rectangle.