heaviside
Heaviside step function.
Category: Mathematics > Mathematical Functions
Syntax
Y = heaviside(X)
Returns 0 for negative, 1/2 at zero and 1 for positive values.
Description
The step function switches a signal on at the origin. Shifted copies such as heaviside(t - 2) turn on at t = 2, and differences of steps build rectangular pulses. Its derivative is dirac. The value at the jump is 1/2 by default, and the choice can be changed with sympref('HeavisideAtOrigin', value).
Input arguments
X- Numeric or symbolic array (real).
Output arguments
Y- Array of the same size. For a symbolic
Xthe callheaviside(x)stays unevaluated.
Example
Step and rectangular pulse
heaviside([-2 0 3])
t = -1:4;
heaviside(t - 1) - heaviside(t - 3)
Output
ans = 1×3
0 0.5000 1.0000
ans = 1×6
0 0 0.5000 1.0000 0.5000 0