Main Content

rectangularPulse

Rectangular pulse function

Description

example

rectangularPulse(a,b,x)returns theRectangular Pulse Function.

rectangularPulse(x)is a shortcut forrectangularPulse(-1/2,1/2,x).

Examples

collapse all

Plot the rectangular pulse function usingfplot.

symsxfplot(rectangularPulse(x), [-1 1])

Figure contains an axes object. The axes object contains an object of type functionline.

Compute the rectangular pulse function for these numbers. Because these numbers are not symbolic objects, you get floating-point results.

[rectangularPulse(-1, 1, -2) rectangularPulse(-1, 1, -1) rectangularPulse(-1, 1, 0) rectangularPulse(-1, 1, 1) rectangularPulse(-1, 1, 2)]
ans = 0 0.5000 1.0000 0.5000 0

Compute the rectangular pulse function for the same numbers in symbolic form.

[rectangularPulse(sym(-1), 1, -2) rectangularPulse(-1, sym(1), -1) rectangularPulse(-1, 1, sym(0)) rectangularPulse(sym(-1), 1, 1) rectangularPulse(sym(-1), 1, 2)]
ans = 0 1/2 1 1/2 0

Show that ifa < b, the rectangular pulse function forx = aandx = bequals1/2.

syms a b x assume(a < b) rectangularPulse(a, b, a) rectangularPulse(a, b, b)
ans = 1/2 ans = 1/2

For further computations, remove the assumptions on the variables by recreating them usingsyms:

syms a b

Fora = b, the rectangular pulse function returns0:

信谊一个x rectangularPulse(a, a, x)
ans = 0

Compute a rectangular pulse of width by usingrectangularPulse(x). This call is equal torectangularPulse(-1/2, 1/2, x).

syms x rectangularPulse(x)
ans = rectangularPulse(-1/2, 1/2, x)
[rectangularPulse(sym(-1)) rectangularPulse(sym(-1/2)) rectangularPulse(sym(0)) rectangularPulse(sym(1/2)) rectangularPulse(sym(1))]
ans = 0 1/2 1 1/2 0

当上升或下降的边缘rectangularPulseisInf, then the result is in terms ofheaviside.

syms x rectangularPulse(-inf, 0, x) rectangularPulse(0, inf, x) rectangularPulse(-inf, inf, x)
ans = heaviside(-x) ans = heaviside(x) ans = 1

Input Arguments

collapse all

Input, specified as a number or a symbolic scalar. This argument specifies the rising edge of the rectangular pulse function.

Input, specified as a number or a symbolic scalar. This argument specifies the falling edge of the rectangular pulse function.

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

More About

collapse all

Rectangular Pulse Function

  • Ifa < x < b, then the rectangular pulse function equals 1.

  • Ifx = aorx = banda <> b, then the rectangular pulse function equals 1/2.

  • Otherwise, it equals 0.

The rectangular pulse function is also called the rectangle function, boxcar function, Pi function, or gate function.

Tips

  • Ifaandbare variables or expressions with variables,rectangularPulseassumes thata < b. Ifaandbare numerical values, such thata > b,rectangularPulsethrows an error.

  • Ifa = b,rectangularPulsereturns 0.

Version History

Introduced in R2012b