# 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.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# `rectangularPulse`

Rectangular pulse function

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

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

## Description

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

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

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

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 < x < b`, the rectangular pulse function equals 1. If `x = a` or `x = b`, the rectangular pulse function equals 1/2. Otherwise, it equals 0. See Example 1 and Example 2.

If `a = b`, `rectangularPulse` returns 0. See Example 3.

`rectangularPulse(x)` is equivalent to ```rectangularPulse(-1/2, 1/2, x)```. See Example 4.

`rectangularPulse` also accepts infinities as its arguments. See Example 7.

`rectangularPulse` and `rectpulse` are equivalent.

## Examples

### Example 1

Compute the rectangular pulse function for these input arguments:

```[rectangularPulse(-1, 1, -2), rectangularPulse(-1, 1, -1), rectangularPulse(-1, 1, 0), rectangularPulse(-1, 1, 1), rectangularPulse(-1, 1, 2)]```

### Example 2

If `a < b`, the rectangular pulse function for `x = a` and `x = b` equals 1/2:

```assume(a < b); [rectangularPulse(a, b, a), rectangularPulse(a, b, b)]```

### Example 3

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

`rectangularPulse(a, a, x)`

### Example 4

Use `rectangularPulse` with one input argument as a shortcut for computing `rectangularPulse(-1/2, 1/2, x)`:

`rectangularPulse(x)`

```[rectangularPulse(-1), rectangularPulse(-1/2), rectangularPulse(0), rectangularPulse(1/2), rectangularPulse(1)]```

### Example 5

Rewrite the rectangular pulse function in terms of the Heaviside step function:

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

### Example 6

Plot the rectangular pulse function:

`plot(rectangularPulse(x), x = -1..1)`

### Example 7

Plot the rectangular pulse function for which the argument `b` is a positive infinity:

`plot(rectangularPulse(0, infinity, x))`

## Parameters

 `a`, `b`, `x` Arithmetical expressions.

## Return Values

Arithmetical expression.

`x`