rectangularPulse
Rectangular pulse function
Description
Examples
Plot Rectangular Pulse Function
Plot the rectangular pulse function usingfplot
.
symsxfplot(rectangularPulse(x), [-1 1])
Compute Rectangular Pulse Function
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
Edge Values of Rectangular Pulse
Show that ifa < b
, the rectangular pulse function forx = a
andx = b
equals1/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
Fixed Rectangular Pulse of Width 1
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
Relation Between Heaviside and Rectangular Pulse
当上升或下降的边缘rectangularPulse
isInf
, 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
a
—Input
-1/2
(default) |number|symbolic scalar
Input, specified as a number or a symbolic scalar. This argument specifies the rising edge of the rectangular pulse function.
b
—Input
-1/2
(default) |number|symbolic scalar
Input, specified as a number or a symbolic scalar. This argument specifies the falling edge of the rectangular pulse function.
x
—Input
number|vector|matrix|array|symbolic number|symbolic variable|symbolic array|symbolic function|symbolic expression
Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.
More About
Rectangular Pulse Function
If
a < x < b
, then the rectangular pulse function equals 1.If
x = a
orx = b
anda <> 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
Version History
Introduced in R2012b
See Also
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)