| Simulink Reference | ![]() |
Perform discrete-time integration or accumulation of a signal
Library
Description
You can use the Discrete-Time Integrator block in place of the Integrator block to create a purely discrete system.
The Discrete-Time Integrator block allows you to
These features are described below.
Integration and Accumulation Methods
The block can integrate or accumulate using the Forward Euler, Backward Euler, and Trapezoidal methods. For a given step n, Simulink updates y(n) and x(n+1). In integration mode, T is the block's sample time (delta T in the case of triggered sample time). In accumulation mode, T = 1; the block's sample time determines when the block's output is computed but not the output's value. K is the gain value. Values are clipped according to upper or lower limits.
For this method, 1/s is approximated by T/(z-1). The resulting expression for the output of the block at step n is
Let x(n+1) = x(n) + K*T*u(n). The block uses the following steps to compute its output:
Step 0: y(0) = x(0) = IC (clip if necessary)x(1) = y(0) + K*T*u(0)Step 1: y(1) = x(1)x(2) = x(1) + K*T*u(1)Step n: y(n) = x(n)x(n+1) = x(n) + K*T*u(n) (clip if necessary)
With this method, input port 1 does not have direct feedthrough.
For this method, 1/s is approximated by T*z/(z-1). The resulting expression for the output of the block at step n is
Let x(n) = y(n-1). The block uses the following steps to compute its output
Step 0: y(0) = x(0) = IC (clipped if necessary)x(1) = y(0)or, depending on Use initial condition as initial and reset value for parameter:Step 0: y(0) = x(0) = IC (clipped if necessary)x(1) = y(0) = x(0) + K*T*u(0)Step 1: y(1) = x(1) + K*T*u(1)x(2) = y(1)Step n: y(n) = x(n) + K*T*u(n)x(n+1) = y(n)
When T is fixed (equal to the sampling period), let
The block uses the following steps to compute its output
Step 0: y(0) = x(0) = IC (clipped if necessary)x(1) = y(0) + K*T/2 * u(0)or, depending on Use initial condition as initial and reset value for parameter:Step 0: y(0) = x(0) = IC (clipped if necessary)x(1) = y(0) = x(0) + K*T/2*u(0)Step 1: y(1) = x(1) + K*T/2 * u(1)x(2) = y(1) + K*T/2 * u(1)Step n: y(n) = x(n) + K*T/2 * u(n)x(n+1) = y(n) + K*T/2 * u(n)
Here, x(n+1) is the best estimate of the next output. It isn't quite the state, in the sense that x(n) != y(n).
If T is variable (i.e. obtained from the triggering times), the block uses the following algorithm to compute its outputs
Step 0: y(0) = x(0) = IC (clipped if necessary) x(1) = y(0) or, depending on Use initial condition as initial and reset value for parameter:Step 0: y(0) = x(0) = IC (clipped if necessary)x(1) = y(0) = x(0) + K*T/2*u(0)Step 1: y(1) = x(1) + T/2 * (u(1) + u(0)) x(2) = y(1) Step n: y(n) = x(n) + T/2 * (u(n) + u(n-1)) x(n+1) = y(n)
The block reflects the selected integration or accumulation method, as this figure shows.
Defining Initial Conditions
You can define the initial conditions as a parameter on the block dialog box or input them from an external signal:
internal and enter the value in the Initial condition parameter field.
external. An additional input port appears under the block input, as shown in this figure.
Using the State Port
In two situations, you must use the state port instead of the output port:
bounce model.
clutch model.
You can correct these problems by passing the state through the state port rather than the output port. Although the values are the same, Simulink generates them at slightly different times, which protects your model from these problems. You output the block state by selecting the Show state port check box.
By default, the state port appears on the top of the block, as shown in this figure.

Limiting the Integral
To prevent the output from exceeding specifiable levels, select the Limit output check box and enter the limits in the appropriate parameter fields. Doing so causes the block to function as a limited integrator. When the output reaches the limits, the integral action is turned off to prevent integral wind up. During a simulation, you can change the limits but you cannot change whether the output is limited. The output is determined as follows:
To generate a signal that indicates when the state is being limited, select the Show saturation port check box. A saturation port appears below the block output port, as shown in this figure.

The signal has one of three values:
Resetting the State
The block can reset its state to the specified initial condition, based on an external signal. To cause the block to reset its state, select one of the External reset parameter choices. A trigger port appears below the block's input port and indicates the trigger type, as shown in this figure.

rising to trigger the state reset when the reset signal has a rising edge.
falling to trigger the state reset when the reset signal has a falling edge.
either to trigger the reset when either a rising or falling signal occurs.
level to trigger the reset and hold the output to the initial condition while the reset signal is nonzero.
The reset port has direct feedthrough. If the block output is fed back into this port, either directly or through a series of blocks with direct feedthrough, an algebraic loop results. To resolve this loop, feed the output of the block's state port into the reset port instead. To access the block's state, select the Show state port check box.
Choosing All Options
When all options are selected, the icon looks like this.

Data Type Support
The Discrete-Time Integrator block accepts real signals of any data type supported by Simulink, including fixed-point data types.
Parameters and Dialog Box
The Main pane of the Discrete-Time Integrator block dialog appears as follows:
internal) or from an external block (external). Simulink does not allow the initial condition of this block to be inf or NaN.
internal. Simulink does not allow the initial condition of this block to be inf or NaN.
State and output,
y(0) = IC
x(0) = IC
y(n) = IC
x(n) = IC
State only (most efficient),
x(0) = IC
x(n) = IC
1. In accumulation mode, the sample time specifies when the block's output is computed. See Specifying Sample Time in the online documentation for information on how to specify the sample time.
The Signal data types pane of the Discrete-Time Integrator block dialog appears as follows:
Specify via dialog for the Output data type and scaling parameter.
Specify via dialog for the Output data type and scaling parameter.
Specify via dialog for the Output data type mode parameter.
The State properties pane of this block pertains to code generation and has no effect on model simulation. See "Block States: Storing and Interfacing" in the Real-Time Workshop documentation for more information.
Characteristics
| Discrete State-Space | Discrete Transfer Fcn | ![]() |
© 1994-2005 The MathWorks, Inc.