rectangularPulse

Rectangular pulse: 1 inside an interval, 0 outside, 1/2 at the edges.

Category: Mathematics > Mathematical Functions

Syntax

Y = rectangularPulse(a, b, x)

Pulse that is 1 for a < x < b.

Y = rectangularPulse(x)

Unit pulse on (-1/2, 1/2).

Description

The pulse is a box function, also known as the window or indicator of an interval, with the usual convention that the value at a jump is the mean of the two sides. It equals heaviside(x - a) - heaviside(x - b).

It is handy for piecewise definitions and as the building block of a signal.

Input arguments

a, b
Left and right edges of the pulse, with a < b.
x
Points at which to evaluate. Scalar or array.

Output arguments

Y
1 inside (a,b), 1/2 at x = a or x = b, 0 elsewhere.

Example

Pulse on [0, 1]

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

         0    0.5000    1.0000    0.5000         0
ans = 0

See also

triangularPulse heaviside sinc rectint