This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Terminate Function

Execute contents on a model terminate event

  • Library:
  • Simulink / User-Defined Functions


The Terminate Function block is a pre-configured subsystem block that executes on a model terminate event. By default, the Terminate Function block includes an Event Listener block with Event set to Terminate, a Terminator block, and a State Reader block.

Replace the Terminator block with blocks to save the state value from the State Reader block.

Conditionally executed subsystem blocks with output ports fully supported within Terminate Function blocks

For a list of unsupported blocks and features, see Initialize, Reset, and Terminate Function Limitations.

The input and output ports of a component containing Initialize Function and Terminate Function blocks must connect to input and output port blocks.

The code generated from this block is part of the model_terminate function that is called once at the end of model execution.

Block Characteristics

Data Types

Boolean[a] | bus[a] | double[a] | enumerated[a] | fixed point[a] | integer[a] | single[a] | string[a]

Direct Feedthrough


Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection


[a] Actual data type or capability support depends on block implementation.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Convert floating-point algorithms to fixed point using Fixed-Point Designer™.