Main Content

Simulink Functions

Define functions that are accessible from across the Simulink model hierarchy

You can use Simulink® functions to define functions that are accessible in the Simulink model hierarchy. A Simulink function calculates a set of outputs based on the provided inputs and the implemented behavior of the function. You can use Simulink functions to:

  • Specify the function prototype which includes the function name, input and output arguments, for example, y = f(u).

  • Implement function behavior in the Simulink environment using a Simulink Function block, an exported function from a Stateflow® chart, or an S-Function block.

  • Call and reuse your function across the model hierarchy.

For more information, see Simulink Functions Overview.

Blocks

expand all

Simulink FunctionDefine a function using Simulink blocks
ChartImplement control logic with finite state machine
Function CallerCall a Simulink function
MATLAB FunctionInclude MATLAB code in Simulink models
ChartImplement control logic with finite state machine
InportCreate input port for subsystem or external input
OutportCreate output port for subsystem or external output
Function ElementSpecify function to be called via exporting function port (Since R2022a)
Function Element CallSpecify function call to be issued via invoking function port (Since R2022a)

Topics

Understanding Simulink Functions

Scoped Simulink Functions

Port-Scoped Simulink Functions

Featured Examples