| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Discrete

You can use the Discrete-Time Integrator block in place of the Integrator block to create a purely discrete system.
For the Discrete-Time Integrator block, you can:
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.
![]()
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.

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 you select all options, the icon looks like this.

If you use simplified initialization mode, the behavior of the Discrete-Time Integrator block differs from its behavior in classic initialization mode. The new initialization behavior is more robust, and provides more consistent behavior in these cases:
In algebraic loops
On enable and disable
When comparing results using triggered sample time against results using explicit sample time, where the block is triggered at the same rate as the explicit sample time
In addition, the simplified initialization behavior makes it easier to convert Continuous-Time Integrator blocks to Discrete-Time Integrator blocks, since the initial conditions have the same meaning for both blocks.
For more information on classic and simplified initialization modes, see Underspecified initialization detection.
When you use simplified initialization mode, the Initial conditions parameter is applied only to the integrator output.
In addition, the Use initial condition as initial and reset value for parameter is disabled. The initial condition is always used as the initial and reset value for the output.
When you use simplified initialization mode, the block starts from first time step n = 0 with initial output y(0) = IC ( clipped if necessary).
For a given step n > 0 with simulation time t(n), Simulink updates output y(n) as follows:
Forward Euler Method:
y(n) = y(n-1) + K*[t(n)-t(n-1)]*u(n-1)
Backward Euler Method:
y(n) = y(n-1) + K*[t(n)-t(n-1)]*u(n)
Trapezoidal Method:
y(n) = y(n-1) + K*[t(n)-t(n-1)]*[u(n)+u(n-1)]/2
Simulink automatically selects a state-space realization of these input-output equations depending on the block sample time, which can be explicit or triggered. When using explicit sample time, t(n)-t(n-1) reduces to the sample time T for all n > 0.
When you use simplified initialization mode, the enable and disable behavior of the block is simplified as follows:
At disable time td:
y(td) = y(td-1)
At enable time te:
If parent subsystem resets on enable:
y(te) = IC
In all other cases (see below):
y(te) = y(td)

When using simplified initialization mode, you cannot place the Discrete-Time Integrator block within an Iterator Subsystem.
In simplified initialization mode, Iterator subsystems do not maintain elapsed time, so Simulink reports an error if any block needing elapsed time, such as the Discrete-Time Integrator, is placed inside an Iterator Subsystem.
The Discrete-Time Integrator block accepts real signals of any numeric data type supported by Simulink software, including fixed-point data types.
The Main pane of the Discrete-Time Integrator block dialog box appears as follows:

The Signal Attributes pane of the Discrete-Time Integrator block dialog box appears as follows:

During simulation, the block uses the following values:
The initial value of the signal object to which the state name is resolved
Min and Max values of the signal object
See Block State Storage and Interfacing Considerations in the Real-Time Workshop User's Guide for more information.
Display the Data Type Assistant.
The Data Type Assistant helps you set the Output data type parameter.
See Specifying Block Output Data Types for more information.
See Block-Specific Parameters for the command-line information.
Specify the integration or accumulation method.
Default: Integration: Forward Euler
Integrator method is Forward Euler.
Integrator method is Backward Euler.
Integrator method is Trapezoidal.
Accumulation method is Forward Euler.
Accumulation method is Backward Euler.
Accumulation method is Trapezoidal.
See Block-Specific Parameters for the command-line information.
Specify a scalar, vector, or matrix by which to multiply the integrator input. Each element of the gain must be a positive real number.
Default: 1.0
Specifying a value other than 1.0 (the default) is semantically equivalent to connecting a signal to the input of the integrator using a Gain block.

Valid entries include:
double(1.0)
single(1.0)
[1.1 2.2 3.3 4.4]
[1.1 2.2; 3.3 4.4]
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.
See Block-Specific Parameters for the command-line information.
Reset the states to their initial conditions when a trigger event occurs in the reset signal.
Default: none
Do not reset the state to initial conditions.
Reset the state when the reset signal has a rising edge.
Reset the state when the reset signal has a falling edge.
Reset the state when the reset signal rises or falls.
Reset and holds the output to the initial condition while the reset signal is nonzero.
Reset the output to the initial condition when the reset signal is nonzero.
See Block-Specific Parameters for the command-line information.
Get the initial conditions of the states.
Default: internal
Get the initial conditions of the states from the Initial condition parameter.
Get the initial conditions of the states from an external block.
Simulink software does not allow the initial condition of this block to be inf or NaN.
Selecting internal enables the Initial condition parameter.
Selecting external disables the Initial condition parameter.
See Block-Specific Parameters for the command-line information.
Specify the states' initial conditions.
Default: 0
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Simulink software does not allow the initial condition of this block to be inf or NaN.
Setting Initial condition source to internal enables this parameter.
Setting Initial condition source to external disables this parameter.
See Block-Specific Parameters for the command-line information.
Specify whether to apply the initial condition as the initial and reset value for the state and output, or the state only.
Note If you are using simplified initialization mode, this parameter is disabled. The initial condition is always used as the initial and reset value for the output. For more information, see Underspecified initialization detection. |
Default: State and output
Set the following for initial
y(0) = IC
x(0) = IC
or at reset
y(n) = IC
x(n) = IC
Set the following for initial
x(0) = IC
or at reset
x(n) = IC
See Block-Specific Parameters for the command-line information.
Enter the discrete interval between sample time hits.
Default: 1
By default, the block uses a discrete sample time of 1. To set a different sample time, enter another discrete value, such as 0.1.
See also How to Specify the Sample Time in the online documentation for more information.
Do not specify a sample time of 0. This value specifies a continuous sample time, which the Discrete-Time Integrator block does not support.
Do not specify a sample time of inf or NaN because these values are not discrete.
If you specify -1 to inherit the sample time from an upstream block, verify that the upstream block uses a discrete sample time. For example, the Discrete-Time Integrator block cannot inherit a sample time of 0.
See Block-Specific Parameters for the command-line information.
Limit the block's output to a value between the Lower saturation limit and Upper saturation limit parameters.
Default: Off
Limit the block's output to a value between the Lower saturation limit and Upper saturation limit parameters.
Do not limit the block's output to a value between the Lower saturation limit and Upper saturation limit parameters.
This parameter enables Upper saturation limit.
This parameter enables Lower saturation limit.
See Block-Specific Parameters for the command-line information.
Specify the upper limit for the integral.
Default: inf
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Limit output enables this parameter.
See Block-Specific Parameters for the command-line information.
Specify the lower limit for the integral.
Default: -inf
Minimum: value of Output minimum parameter
Maximum: value of Output maximum parameter
Limit output enables this parameter.
See Block-Specific Parameters for the command-line information.
Add a saturation output port to the block.
Default: Off
See Block-Specific Parameters for the command-line information.
Add an output port to the block for the block's state.
Default: Off
Add an output port to the block for the block's state.
Do not add an output port to the block for the block's state.
See Block-Specific Parameters for the command-line information.
Cause Simulink linearization commands to treat this block as not resettable and as having no limits on its output, regardless of the settings of the block reset and output limitation options.
Default: Off
Cause Simulink linearization commands to treat this block as not resettable and as having no limits on its output, regardless of the settings of the block reset and output limitation options.
Do not cause Simulink linearization commands to treat this block as not resettable and as having no limits on its output, regardless of the settings of the block reset and output limitation options.
Ignoring the limit and resetting allows you to linearize a model around an operating point. This point may cause the integrator to reset or saturate.
See Block-Specific Parameters for the command-line information.
Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor.
Default: Off
Locks the output data type setting for this block.
Allows the Fixed-Point Tool and the Fixed-Point Advisor to change the output data type setting for this block.
See Block-Specific Parameters for the command-line information.
For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.
Select the rounding mode for fixed-point operations.
Default: Floor
Round both positive and negative numbers toward positive infinity.
Round number to the nearest representable value. If a tie occurs, round to the nearest even stored value.
Round both positive and negative numbers toward negative infinity.
Round number to the nearest representable value. If a tie occurs, round toward positive infinity.
Round number to the nearest representable value. If a tie occurs, round positive numbers toward positive infinity and round negative numbers toward negative infinity.
This option provides for an optimization of the rounding code for several blocks.
Round number toward zero.
See Block-Specific Parameters for the command-line information.
For more information, see Rounding in the Simulink Fixed Point User's Guide.
Specify whether overflows saturate.
Default: Off
When you select this check box, saturation applies to every internal operation on the block, not just the output or result.
In general, the code generation process can detect when overflow is not possible, in which case, no saturation code is necessary.
See Block-Specific Parameters for the command-line information.
Use this parameter to assign a unique name to each state.
Default: ' '
If left blank, no name is assigned.
To assign a name to a single state, enter the name between quotes, for example, 'velocity' .
The state names apply only to the selected block.
To assign names to multiple states, enter a comma-delimited list surrounded by braces. For example, {'a', 'b', 'c'} . Each name must be unique.
The number of states must be evenly divided by the number of state names. There can be fewer names than states, but there cannot be more names than states.
For example, you can specify two names in a system with four states. Simulink software will assign the first name to the first two states and the second name to the last two.
To assign state names with a variable that has been defined in the MATLAB workspace, enter the variable without quotes. A variable can be a string, cell, or structure.
This parameter enables State name must resolve to Simulink signal object when you click the Apply button.
See Block-Specific Parameters for the command-line information.
Require that state name resolve to Simulink signal object.
Default: Off
Require that state name resolve to Simulink signal object.
Do not require that state name resolve to Simulink signal object.
State name enables this parameter.
This parameter enables Real-Time Workshop storage class.
See Block-Specific Parameters for the command-line information.
Select state storage class.
Default: Auto
Auto is the appropriate storage class for states that you do not need to interface to external code.
State is stored in a global variable
model_private.h declares the state as an extern variable.
model_private.h declares the state as an extern pointer.
State name enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables Real-Time Workshop storage type qualifier.
See Block-Specific Parameters for the command-line information.
Specify Real-Time storage type qualifier.
Default: ' '
If left blank, no qualifier is assigned.
Setting Real-Time Workshop storage class to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables this parameter.
See Block-Specific Parameters for the command-line information.
Specify the minimum value that the block should output.
Default: []
The default value, [], is equivalent to -Inf.
Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values) for some blocks
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
This number must be a double scalar value.
See Block-Specific Parameters for the command-line information.
Specify the maximum value that the block should output.
Default: []
The default value, [], is equivalent to Inf.
Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values) for some blocks
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
This number must be a double scalar value.
See Block-Specific Parameters for the command-line information.
Specify the output data type.
Default: Inherit: Inherit via internal rule (Discrete-Time Integrator, Gain, Product, Sum, Switch block), Inherit: Inherit from 'Constant value' (Constant block), Inherit: Inherit via back propagation (Data Type Conversion block), Inherit: Same as input (Saturation block)
This option appears for some blocks. Simulink software chooses a combination of output scaling and data type that requires the smallest amount of memory consistent with accommodating the calculated output range and maintaining the output precision of the block and with the word size of the targeted hardware implementation specified for the model. If the Device type parameter on the Hardware Implementation configuration parameters pane is set to ASIC/FPGA, Simulink software chooses the output data type without regard to hardware constraints. Otherwise, Simulink software chooses the smallest available hardware data type capable of meeting the range and precision constraints. For example, if the block multiplies an input of type int8 by a gain of int16 and ASIC/FPGA is specified as the targeted hardware type, the output data type is sfix24. If Unspecified (assume 32-bit Generic), i.e., a generic 32-bit microprocessor, is specified as the target hardware, the output data type is int32. If none of the word lengths provided by the target microprocessor can accommodate the output range, Simulink software displays an error message in the Simulation Diagnostics Viewer.
Use data type of Constant value parameter. This option appears for some blocks.
Use data type of the driving block.
Use data type of sole input signal. This option appears for some blocks.
Use data type of first input signal. This option appears for some blocks.
Output data type is the same as accumulator data type. This option appears for some blocks.
Output data type is double.
Output data type is single.
Output data type is int8.
Output data type is uint8.
Output data type is int16.
Output data type is uint16.
Output data type is int32.
Output data type is unt32.
Output data type is fixed point fixdt(1,16,0).
Output data type is fixed point fixdt(1,16,2^0,0).
Use an enumerated data type, for example, Enum: BasicColors. This option appears for some blocks.
Use a data type object, for example, Simulink.NumericType.
See Block-Specific Parameters for the command-line information.
See Specifying Block Output Data Types in the Simulink User's Guide for more information.
Select the category of data to specify.
Default: Inherit (Constant, Data Type Conversion, Discrete Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch), Built in (Logical Operator, Relational Operator)
Inheritance rules for data types. Selecting Inherit enables a second menu/text box to the right. The following list is the possible values, which can vary by block:
Inherit from 'Constant value' (Constant block default)
Inherit via internal rule (Discrete-Time Integrator, Gain, Product, Sum, Switch block default)
Inherit via back propogation (Data Type Conversion block default)
auto (Inport, Outport block default)
Logical (see Configuration Parameters: Optimization)
Same as first input
Same as input (Saturation block default)
Same as accumulator
Built-in data types. Selecting Built in enables a second menu/text box to the right. The following list is the possible values, which can vary by block:
double (Constant, Data Type Conversion, Discrete-Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch block default)
single
int8
uint8
int16
uint16
int32
uint32
boolean (Logical Operator, Relational Operator block default)
Fixed-point data types.
Enumerated data types. This option is available on some blocks. Selecting Enumerated enables a second menu/text box to the right. The following list is the possible values, which can vary by block:
<class name>
Expressions that evaluate to data types. Selecting Expression enables a second menu/text box to the right. The following list is the possible values, which can vary by block:
<data type expression>
Clicking the Show data type assistant button enables this parameter.
See Block-Specific Parameters for the command-line information.
See Using the Data Type Assistant in the Simulink User's Guide.
Specify whether you want the fixed-point data as signed or unsigned.
Default: Signed
Selecting Mode > Fixed point enables this parameter.
See Block-Specific Parameters for the command-line information.
See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.
Specify the bit size of the word that holds the quantized integer.
Default: 16
Minimum: 0
Maximum: 32
Large word sizes represent large values with greater precision than small word sizes.
Selecting Mode > Fixed point enables this parameter.
See Block-Specific Parameters for the command-line information.
See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.
Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.
Default: Best precision (Constant), Binary point (Data Type Conversion, Discrete-Time Integrator, Gain, Inport, Outport, Product, Saturation, Sum, Switch), Integer (Logical Operator, Relational Operator)
Specify binary point location.
Enter slope and bias.
Specify best-precision values. This option appears for some blocks.
Specify integer. This setting has the same result as specifying a binary point location and setting fraction length to 0. This option appears for some blocks.
Selecting Mode > Fixed point enables this parameter.
Selecting Binary point enables:
Fraction length
Calculate Best-Precision Scaling
Selecting Slope and bias enables:
Slope
Bias
Calculate Best-Precision Scaling
See Block-Specific Parameters for the command-line information.
See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.
Specify fraction length for fixed-point data type.
Default: 0
Binary points can be positive or negative integers.
Selecting Scaling > Binary point enables this parameter.
See Block-Specific Parameters for the command-line information.
See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.
Specify slope for the fixed-point data type.
Default: 2^0
Specify any positive real number.
Selecting Scaling > Slope and bias enables this parameter.
See Block-Specific Parameters for the command-line information.
See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.
Specify bias for the fixed-point data type.
Default: 0
Specify any real number.
Selecting Scaling > Slope and bias enables this parameter.
See Block-Specific Parameters for the command-line information.
See Specifying a Fixed-Point Data Type in the Simulink 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 Detection | No |
![]() | Discrete State-Space | Discrete Transfer Fcn | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |