| Simulink® | ![]() |
Discrete

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
Define initial conditions on the block dialog box or as input to the block.
Define an input gain (K) value.
Output the block state.
Define upper and lower limits on the integral.
Reset the state depending on an additional reset input.
These features are described below.
The block can integrate or accumulate using the Forward Euler, Backward Euler, and Trapezoidal methods. For a given step n, Simulink® software 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.
Forward Euler method (the default), also known as Forward Rectangular, or left-hand approximation.
For this method, 1/s is approximated by T/(z-1). The resulting expression for the output of the block at step n is
y(n) = y(n-1) + K*T*u(n-1)
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.
Backward Euler method, also known as Backward Rectangular or right-hand approximation.
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
y(n) = y(n-1) + K*T*u(n)
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: 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)
With this method, input port 1 has direct feedthrough.
Trapezoidal method. For this method, 1/s is approximated by
T/2*(z+1)/(z-1)
When T is fixed (equal to the sampling period), let
x(n) = y(n-1) + K*T/2 * u(n-1)
The block uses the following steps to compute its output
Step 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)
With this method, input port 1 has direct feedthrough.
The block reflects the selected integration or accumulation method, as this figure shows.
![]()
You can define the initial conditions as a parameter on the block dialog box or input them from an external signal:
To define the initial conditions as a block parameter, specify the Initial condition source parameter as internal and enter the value in the Initial condition parameter field.
To provide the initial conditions from an external source, specify the Initial condition source parameter as external. An additional input port appears under the block input, as shown in this figure.

In two situations, you must use the state port instead of the output port:
When the output of the block is fed back into the block through the reset port or the initial condition port, causing an algebraic loop. For an example of this situation, see the sldemo_bounce model.
When you want to pass the state from one conditionally executed subsystem to another, which can cause timing problems. For an example of this situation, see the sldemo_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 software 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.

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:
When the integral is less than or equal to the Lower saturation limit and the input is negative, the output is held at the Lower saturation limit.
When the integral is between the Lower saturation limit and the Upper saturation limit, the output is the integral.
When the integral is greater than or equal to the Upper saturation limit and the input is positive, the output is held at the Upper saturation limit.
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:
1 indicates that the upper limit is being applied.
0 indicates that the integral is not limited.
-1 indicates that the lower limit is being applied.
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.

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.
The External reset parameter lets you determine the attribute of the reset signal that triggers the reset. The trigger options include:
rising
Resets the state when the reset signal has a rising edge. For example, the following figure shows the effect that a rising reset trigger has on backward Euler integration.

falling
Resets the state when the reset signal has a falling edge. For example, the following figure shows the effect that a falling reset trigger has on backward Euler integration.

either
Resets the state when the reset signal rises or falls. For example, the following figure shows the effect that an either reset trigger has on backward Euler integration.

level
Resets and holds the output to the initial condition while the reset signal is nonzero. For example, the following figure shows the effect that a level reset trigger has on backward Euler integration.

sampled level
Resets the output to the initial condition when the reset signal is nonzero. For example, the following figure shows the effect that a sampled level reset trigger has on backward Euler integration.

When all options are selected, the icon looks like this.

The Discrete-Time Integrator block accepts real signals of any data type supported by Simulink software, including fixed-point data types.
The Main pane of the Discrete-Time Integrator block dialog appears as follows:

Specify the integration or accumulation method.
Specify a value by which to multiply the integrator input. Specifying a value other than 1.0 (the default) is semantically equivalent to connecting a signal to the input of the integrator via a Gain block, i.e., to

Using this parameter to specify the input gain eliminates a multiplication operation in the generated code. Realizing this benefit, however, requires that this parameter be nontunable. Accordingly, the Real-Time Workshop® software generates a warning during code generation if the Model Parameter Configuration dialog box for this model declares this parameter to be tunable. If you want to tune the input gain, set this parameter to 1.0 and use an external Gain block to specify the input gain.
Resets the states to their initial conditions when a trigger event occurs in the reset signal. See Resetting the State for more information.
Gets the states' initial conditions from the Initial condition parameter (internal) or from an external block (external). Simulink software does not allow the initial condition of this block to be inf or NaN.
The states' initial conditions. This parameter is only available if the Initial condition source parameter is set to internal. Simulink software does not allow the initial condition of this block to be inf or NaN.
When you set this parameter to State and output,
y(0) = IC
x(0) = IC
or at reset
y(n) = IC
x(n) = IC
When you set this parameter to State only (most efficient),
x(0) = IC
or at reset
x(n) = IC
The time interval between samples. The default is 1. In accumulation mode, the sample time specifies when the block's output is computed. See Specifying Sample Time.
If selected, limits the block's output to a value between the Lower saturation limit and Upper saturation limit parameters.
The upper limit for the integral. This parameter is only available if you select the Limit output parameter.
The lower limit for the integral. This parameter is only available if you select the Limit output parameter.
If selected, adds a saturation output port to the block.
If selected, adds an output port to the block for the block's state.
Select this option to cause Simulink linearization commands to treat this block as unresettable and as having no limits on its output, regardless of the settings of the block's reset and output limitation options. This allows you to linearize a model around an operating point that causes the integrator to reset or saturate.
The Signal Attributes pane of the Discrete-Time Integrator block dialog appears as follows:

Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output
data type parameter.
See Specifying Block Output Data Types for more information.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.
Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink® Fixed Point™ User's Guide.
Select to have overflows saturate.
The State Attributes pane of this block pertains to code generation and has no effect on model simulation. See Block State Storage and Interfacing in the Real-Time Workshop User's Guide for more information.
Direct Feedthrough | Yes, of the reset and external initial condition source ports. The input has direct feedthrough for every integration method except forward Euler and accumulation forward Euler. |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes, of parameters |
States | Inherited from driving block and parameter |
Dimensionalized | Yes |
Zero Crossing | No |
![]() | Discrete State-Space | Discrete Transfer Fcn | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |