# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# rectangularPulse

Rectangular pulse function

## Syntax

```rectangularPulse(a,b,x) rectangularPulse(x) ```

## Description

`rectangularPulse(a,b,x)` returns the rectangular pulse function.

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

## Input Arguments

 `a` Number (including infinities and symbolic numbers), symbolic variable, or symbolic expression. This argument specifies the rising edge of the rectangular pulse function. Default: `-1/2` `b` Number (including infinities and symbolic numbers), symbolic variable, or symbolic expression. This argument specifies the falling edge of the rectangular pulse function. Default: `1/2` `x` Number (including infinities and symbolic numbers), symbolic variable, or symbolic expression.

## Examples

### Find 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 numbers converted to symbolic objects:

```[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

If `a < b`, the rectangular pulse function for `x = a` and `x = b` equals `1/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 assumption:

`syms a b clear`

For `a = b`, the rectangular pulse function returns `0`:

```syms a x rectangularPulse(a, a, x)```
```ans = 0```

### Fixed Rectangular Pulse of Width 1

Use `rectangularPulse` with one input argument as a shortcut for computing `rectangularPulse(-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```

### Plot Rectangular Pulse Function

Plot the rectangular pulse function using `fplot`. Prior to R2016a, use `ezplot` instead of `fplot`.

```syms x fplot(rectangularPulse(x), [-1 1])```

### Relation Between Heaviside and Rectangular Pulse

Call `rectangularPulse` with infinities as its rising and falling edges:

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

collapse all

### Rectangular Pulse Function

The rectangular pulse function is defined as follows:

If `a < x < b`, then the rectangular pulse function equals 1. If `x = a` or ```x = b``` and `a <> b`, then the rectangular pulse function equals 1/2. Otherwise, it equals 0.

The rectangular pulse function is also called the rectangle function, box function, Π-function, or gate function.

## Tips

• If `a` and `b` are variables or expressions with variables, `rectangularPulse` assumes that `a < b`. If `a` and `b` are numerical values, such that `a > b`, `rectangularPulse` throws an error.

• If `a = b`, `rectangularPulse` returns 0.