triangularPulse

Triangular pulse that rises from a to b and falls from b to c.

Category: Mathematics > Mathematical Functions

Syntax

Y = triangularPulse(a, b, c, x)

Triangle with feet at a and c and peak 1 at x = b.

Y = triangularPulse(a, c, x)

Symmetric triangle: the peak is at the midpoint of a and c.

Y = triangularPulse(x)

Unit triangle with feet at -1 and 1.

Description

The function is piecewise linear and continuous. It is 0 for x <= a, climbs linearly to 1 at x = b, then falls linearly to 0 at x = c, staying 0 afterwards. It models a triangular window or a fuzzy membership function.

Input arguments

a, b, c
Left foot, peak position and right foot, with a < b < c.
x
Points at which to evaluate. Scalar or array.

Output arguments

Y
Values between 0 and 1: linear on [a,b] and [b,c], and 0 outside [a,c].

Example

Asymmetric triangle

x = [0 0.5 1 2 4];
triangularPulse(0, 1, 4, x)
triangularPulse(-1, 0, 1, 0.5)
Output
ans = 1×5

         0    0.5000    1.0000    0.6667         0
ans = 0.5000

See also

rectangularPulse heaviside sinc interp1