Skip to Main Content Skip to Search
Product Documentation

Discrete-Time Integrator - Perform discrete-time integration or accumulation of signal

Library

Discrete

Description

Capabilities of the Discrete-Time Integrator Block

You can use the Discrete-Time Integrator block in place of the Integrator block to create a purely discrete system. With the Discrete-Time Integrator block, you can:

Integration and Accumulation Methods

The block can integrate or accumulate using the Forward Euler, Backward Euler, and Trapezoidal methods. Assume that u is the input, y is the output, and x is the state. For a given step n, Simulink updates y(n) and x(n+1). In integration mode, T is the block sample time (delta T in the case of triggered sample time). In accumulation mode, T = 1; the block sample time determines when the output is computed but not the output value. K is the gain value. Values clip according to upper or lower limits.

How to Define Initial Conditions

You can define the initial conditions as a parameter on the block dialog box or input them from an external signal:

When to Use the State Port

In two situations, you must use the state port instead of the output port:

You can work around these problems by passing the state through the state port rather than the output port. Simulink generates the state at a slightly different time from the output, 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:

How to Limit 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 block determines output as follows:

When the integral is...The output is...
Less than or equal to the Lower saturation limit and the input is negativeHeld at the Lower saturation limit
Between the Lower saturation limit and the Upper saturation limitThe integral
Greater than or equal to the Upper saturation limit and the input is positiveHeld 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:

The signal has one of three values:

How to Reset the State

The block can reset its state to the initial condition you specify, 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 input port to indicate the trigger type:

The reset port has direct feedthrough. If the block output feeds 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 state port into the reset port instead. To access the block state, select the Show state port check box.

Reset Trigger Types

The External reset parameter lets you determine the attribute of the reset signal that triggers the reset. The trigger options include:

Block Icon When Selecting All Options

When you select all options, the icon looks like this:

Behavior When Using Simplified Initialization Mode

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 addition, the simplified initialization behavior makes it easier to convert Continuous-Time Integrator blocks to Discrete-Time Integrator blocks, because the initial conditions have the same meaning for both blocks.

For more information on classic and simplified initialization modes, see Underspecified initialization detection.

Initial Conditions in Simplified Initialization Mode

When you use simplified initialization mode, the Initial condition parameter applies only to the integrator output.

In addition, the Use initial condition as initial and reset value for parameter is disabled. The block uses the initial condition as the initial and reset value for the output.

Input-Output Equations in Simplified Initialization Mode

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:

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.

Enable and Disable Behavior in Simplified Initialization Mode

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:

Iterator Subsystems

When using simplified initialization mode, you cannot place the Discrete-Time Integrator block in 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 block.

Behavior When Used in an Enabled Subsystem Inside a Function-Call Subsystem

Suppose that you have a function-call subsystem that contains an enabled subsystem, which contains a Discrete-Time Integrator block. The following behavior applies.

Integrator MethodSample Time Type of Function-Call Trigger PortValue of delta T When Function-Call Subsystem Executes for the First Time After EnabledReason for Behavior

Forward Euler

Triggered

t — tstart

When the function-call subsystem executes for the first time, the integrator algorithm uses tstart as the previous simulation time.

Backward Euler and Trapezoidal

Triggered

t — tprevious

When the function-call subsystem executes for the first time, the integrator algorithm uses tprevious as the previous simulation time.

Forward Euler, Backward Euler, and Trapezoidal

Periodic

Sample time of the function-call generator

In periodic mode, the Discrete-Time Integrator block uses sample time of the function-call generator for delta T.

Data Type Support

The Discrete-Time Integrator block accepts real signals of the following data types:

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

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:

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

During simulation, the block uses the following values:

For more information, see States in the Simulink Coder documentation.

Show data type assistant

Display the Data Type Assistant.

Settings

The Data Type Assistant helps you set the Output data type parameter.

See Specifying Block Output Data Types for more information.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Integrator method

Specify the integration or accumulation method.

Settings

Default: Integration: Forward Euler

Integration: Forward Euler

Integrator method is Forward Euler.

Integration: Backward Euler

Integrator method is Backward Euler.

Integration: Trapezoidal

Integrator method is Trapezoidal.

Accumulation: Forward Euler

Accumulation method is Forward Euler.

Accumulation: Backward Euler

Accumulation method is Backward Euler.

Accumulation: Trapezoidal

Accumulation method is Trapezoidal.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Gain value

Specify a scalar, vector, or matrix by which to multiply the integrator input. Each element of the gain must be a positive real number.

Settings

Default: 1.0

Command-Line Information

See Block-Specific Parameters for the command-line information.

External reset

Reset the states to their initial conditions when a trigger event occurs in the reset signal.

Settings

Default: none

none

Do not reset the state to initial conditions.

rising

Reset the state when the reset signal has a rising edge.

falling

Reset the state when the reset signal has a falling edge.

either

Reset the state when the reset signal rises or falls.

level

Reset and holds the output to the initial condition while the reset signal is nonzero.

sampled level

Reset the output to the initial condition when the reset signal is nonzero.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Initial condition source

Get the initial conditions of the states.

Settings

Default: internal

internal

Get the initial conditions of the states from the Initial condition parameter.

external

Get the initial conditions of the states from an external block.

Tips

Simulink software does not allow the initial condition of this block to be inf or NaN.

Dependencies

Selecting internal enables the Initial condition parameter.

Selecting external disables the Initial condition parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Initial condition

Specify the states' initial conditions.

Settings

Default: 0

Minimum: value of Output minimum parameter

Maximum: value of Output maximum parameter

Tips

Simulink software does not allow the initial condition of this block to be inf or NaN.

Dependencies

Setting Initial condition source to internal enables this parameter.

Setting Initial condition source to external disables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Use initial condition as initial and reset value for

Specify whether to apply the initial condition as the initial and reset value for the state and output, or the state only.

Settings

Default: State and output

State and output

Set the following for initial

y(0) = IC

x(0) = IC

or at reset

y(n) = IC

x(n) = IC

State only (most efficient)

Set the following for initial

x(0) = IC

or at reset

x(n) = IC

Command-Line Information

See Block-Specific Parameters for the command-line information.

Sample time (-1 for inherited)

Enter the discrete interval between sample time hits.

Settings

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.

Tips

Command-Line Information

See Block-Specific Parameters for the command-line information.

Limit output

Limit the block's output to a value between the Lower saturation limit and Upper saturation limit parameters.

Settings

Default: Off

On

Limit the block's output to a value between the Lower saturation limit and Upper saturation limit parameters.

Off

Do not limit the block's output to a value between the Lower saturation limit and Upper saturation limit parameters.

Dependencies

This parameter enables Upper saturation limit.

This parameter enables Lower saturation limit.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Upper saturation limit

Specify the upper limit for the integral.

Settings

Default: inf

Minimum: value of Output minimum parameter

Maximum: value of Output maximum parameter

Dependencies

Limit output enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Lower saturation limit

Specify the lower limit for the integral.

Settings

Default: -inf

Minimum: value of Output minimum parameter

Maximum: value of Output maximum parameter

Dependencies

Limit output enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Show saturation port

Add a saturation output port to the block.

Settings

Default: Off

On

Add a saturation output port to the block.

Off

Do not add a saturation output port to the block.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Show state port

Add an output port to the block for the block's state.

Settings

Default: Off

On

Add an output port to the block for the block's state.

Off

Do not add an output port to the block for the block's state.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Ignore limit and reset when linearizing

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.

Settings

Default: Off

On

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.

Off

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.

Tips

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.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Lock output data type setting against changes by the fixed-point tools

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor.

Settings

Default: Off

On

Locks the output data type setting for this block.

Off

Allows the Fixed-Point Tool and the Fixed-Point Advisor to change the output data type setting for this block.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.

Integer rounding mode

Specify the rounding mode for fixed-point operations.

Settings

Default: Floor

Ceiling

Rounds both positive and negative numbers toward positive infinity. Equivalent to the MATLAB ceil function.

Convergent

Rounds number to the nearest representable value. If a tie occurs, rounds to the nearest even integer. Equivalent to the Fixed-Point Toolbox convergent function.

Floor

Rounds both positive and negative numbers toward negative infinity. Equivalent to the MATLAB floor function.

Nearest

Rounds number to the nearest representable value. If a tie occurs, rounds toward positive infinity. Equivalent to the Fixed-Point Toolbox nearest function.

Round

Rounds number to the nearest representable value. If a tie occurs, rounds positive numbers toward positive infinity and rounds negative numbers toward negative infinity. Equivalent to the Fixed-Point Toolbox round function.

Simplest

Automatically chooses between round toward floor and round toward zero to generate rounding code that is as efficient as possible.

Zero

Rounds number toward zero. Equivalent to the MATLAB fix function.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

For more information, see Rounding in the Simulink Fixed Point User's Guide.

Saturate on integer overflow

Specify whether overflows saturate.

Settings

Default: Off

On

Overflows saturate to either the minimum or maximum value that the data type can represent.

For example, an overflow associated with a signed 8-bit integer can saturate to -128 or 127.

Off

Overflows wrap to the appropriate value that is representable by the data type.

For example, the number 130 does not fit in a signed 8-bit integer and wraps to -126.

Tips

Command-Line Information

See Block-Specific Parameters for the command-line information.

State name

Use this parameter to assign a unique name to each state.

Settings

Default: ' '

Tips

Dependency

This parameter enables State name must resolve to Simulink signal object when you click the Apply button.

For more information, see States in the Simulink Coder documentation.

Command-Line Information

See Block-Specific Parameters for the command-line information.

State name must resolve to Simulink signal object

Require that state name resolve to Simulink signal object.

Settings

Default: Off

On

Require that state name resolve to Simulink signal object.

Off

Do not require that state name resolve to Simulink signal object.

Dependencies

State name enables this parameter.

Selecting this check box disables Code generation storage class.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Package

Select a package that defines the custom storage class you want to apply.

Settings

Default: ---None---

---None---

Sets internal storage class attributes.

mpt

Applies the built-in mpt package.

Simulink

Applies the built-in Simulink package.

Dependencies

If you have defined any packages of your own, click Refresh. This action adds all user-defined packages on your search path to the package list.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Code generation storage class

Select state storage class.

Settings

Default: Auto

Auto

Auto is the appropriate storage class for states that you do not need to interface to external code.

ExportedGlobal

State is stored in a global variable

ImportedExtern

model_private.h declares the state as an extern variable.

ImportedExternPointer

model_private.h declares the state as an extern pointer.

Dependencies

State name enables this parameter.

Setting this parameter to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables Code generation storage type qualifier.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

State Storage Classes in the Simulink Coder documentation.

Code generation storage class (when Package is selected)

Select custom storage class for state.

Settings

Default: Auto

Auto

Auto is the appropriate storage class for states that you do not need to interface to external code.

SimulinkGlobal

model_P initializes the state to its corresponding value in the workspace.

ExportedGlobal

State is stored in a global variable

ImportedExtern

model_private.h declares the state as an extern variable.

ImportedExternPointer

model_private.h declares the state as an extern pointer.

Default

A non-editable placeholder storage class is created.

BitField

A struct declaration is created that embeds Boolean data.

Volatile

Volatile type qualifier is used in state declaration.

ExportToFile

Header (.h) file containing global variable declarations is generated with user-specified name.

ImportFromFile

Predefined header (.h) files containing global variable declarations are included.

FileScope

A static qualifier is generated in front of the state declaration to make the state visible only to the current file.

Struct

A struct declaration is created to encapsulate parameter or signal object data.

StructVolatile

Volatile type qualifier is used in struct declaration.

GetSet

Supports specialized function calls to read and write memory.

Dependencies

State name enables this parameter.

The list of valid storage classes differs based on the Package selection.

Setting this parameter to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables Code generation storage type qualifier.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

State Storage Classes in the Simulink Coder documentation.

Code generation storage type qualifier

Specify the Simulink Coder storage type qualifier.

Settings

Default: ' '

If left blank, no qualifier is assigned.

Dependency

Setting Code generation storage class to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output minimum

Specify the minimum value that the block should output.

Settings

Default: [] (unspecified)

This number must be a finite real double scalar value.

Simulink uses the minimum to perform:

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output maximum

Specify the maximum value that the block should output.

Settings

Default: [] (unspecified)

This number must be a finite real double scalar value.

Simulink uses the maximum value to perform:

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output data type

Specify the output data type.

Settings

Default: Inherit: Inherit via internal rule

Inherit: Inherit via internal rule

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

Inherit: Inherit via back propagation

Use data type of the driving block.

double

Output data type is double.

single

Output data type is single.

int8

Output data type is int8.

uint8

Output data type is uint8.

int16

Output data type is int16.

uint16

Output data type is uint16.

int32

Output data type is int32.

uint32

Output data type is uint32.

fixdt(1,16,0)

Output data type is fixed point fixdt(1,16,0).

fixdt(1,16,2^0,0)

Output data type is fixed point fixdt(1,16,2^0,0).

<data type expression>

Use a data type object, for example, Simulink.NumericType.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying Block Output Data Types in the Simulink User's Guide for more information.

Mode

Select the category of data to specify.

Settings

Default: Inherit

Inherit

Inheritance rules for data types. Selecting Inherit enables a second menu/text box to the right. Select one of the following choices:

  • Inherit via internal rule (default)

  • Inherit via back propagation

Built in

Built-in data types. Selecting Built in enables a second menu/text box to the right. Select one of the following choices:

  • double (default)

  • single

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

Fixed point

Fixed-point data types.

Expression

Expressions that evaluate to data types. Selecting Expression enables a second menu/text box to the right, where you can enter the expression.

Dependency

Clicking the Show data type assistant button enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Using the Data Type Assistant in the Simulink User's Guide.

Data type override

Specify data type override mode for this signal.

Settings

Default: Inherit

Inherit

Inherits the data type override setting from its context, that is, from the block, Simulink.Signal object or Stateflow chart in Simulink that is using the signal.

Off

Ignores the data type override setting of its context and uses the fixed-point data type specified for the signal.

Tip

The ability to turn off data type override for an individual data type provides greater control over the data types in your model when you apply data type override. For example, you can use this option to ensure that data types meet the requirements of downstream blocks regardless of the data type override setting.

Dependency

This parameter appears only when the Mode is Built in or Fixed point.

Signedness

Specify whether you want the fixed-point data as signed or unsigned.

Settings

Default: Signed

Signed

Specify the fixed-point data as signed.

Unsigned

Specify the fixed-point data as unsigned.

Dependencies

Selecting Mode > Fixed point enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Word length

Specify the bit size of the word that holds the quantized integer.

Settings

Default: 16

Minimum: 0

Maximum: 32

Dependencies

Selecting Mode > Fixed point enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.

Settings

Default: Best precision

Binary point

Specify binary point location.

Slope and bias

Enter slope and bias.

Best precision

Specify best-precision values.

Dependencies

Selecting Mode > Fixed point enables this parameter.

Selecting Binary point enables:

Selecting Slope and bias enables:

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Fraction length

Specify fraction length for fixed-point data type.

Settings

Default: 0

Binary points can be positive or negative integers.

Dependencies

Selecting Scaling > Binary point enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Slope

Specify slope for the fixed-point data type.

Settings

Default: 2^0

Specify any positive real number.

Dependencies

Selecting Scaling > Slope and bias enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Bias

Specify bias for the fixed-point data type.

Settings

Default: 0

Specify any real number.

Dependencies

Selecting Scaling > Slope and bias enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specifying a Fixed-Point Data Type in the Simulink User's Guide for more information.

Examples

The sldemo_fuelsys model uses a Discrete-Time Integrator block in the fuel_rate_control/airflow_calc subsystem. This block uses the Forward Euler integration method.

When the Switch block feeds a nonzero value into the Discrete-Time Integrator block, integration occurs. Otherwise, integration does not occur.

For more information, see the model description.

Characteristics

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

Multidimensionalized

No

Zero-Crossing Detection

No

See Also

Integrator

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS