Main Content

Simulink Functions

R2026b
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 Function blockSimulink FunctionDefine a function using Simulink blocks
Chart blockChartImplement control logic with finite state machine
Function Caller blockFunction CallerCall a Simulink function
MATLAB Function block icon.MATLAB FunctionInclude MATLAB code in Simulink models
Chart blockChartImplement control logic with finite state machine
Inport blockInportCreate input port for subsystem or external input
Outport blockOutportCreate output port for subsystem or external output
Function Element blockFunction ElementSpecify function to provide via exporting function port (Since R2022a)
Function Element Call blockFunction Element CallSpecify function call to issue via invoking function port (Since R2022a)

Topics

Understanding Simulink Functions

Scoped Simulink Functions

Port-Scoped Simulink Functions

Featured Examples