Simulink Functions

Create functions accessible in Simulink models

A Simulink® function is a computational unit that calculates a set of outputs when provided with a set of inputs. Since a Simulink function provides a common text interface to its function definition and a function caller, how you define the function is your choice. Possible function definitions include using:

  • Simulink blocks in a Simulink Function block

  • Stateflow® state transitions in an exported Stateflow graphical function

  • MATLAB® code statements in an exported Stateflow MATLAB function

After you define a function, you can call it using a Function Caller block, MATLAB Function block or Stateflow Chart.


expand all

Simulink FunctionFunction defined with Simulink blocks
Argument InportArgument input port for Simulink Function block
Argument OutportArgument output port for Simulink Function block
Function CallerCall Simulink or exported Stateflow function
MATLAB FunctionInclude MATLAB code in models that generate embeddable C code
ChartImplement control logic with finite state machine
InportCreate input port for subsystem or external input
OutportCreate output port for subsystem or external output


Simulink Functions Overview

Functions in a Simulink model that share a common text interface with function callers.

Using Simulink Function Blocks and Exported Stateflow Functions

Add functions and function callers to a Simulink model.

Simulink Function Blocks in Referenced Models

Add and access functions in model components.

Scoped and Global Simulink Function Blocks Overview

Specify visibility and access of Simulink Function blocks

Scoped Simulink Function Blocks in Subsystems

Limit the scope of a function to a subsystem.

Scoped Simulink Function Blocks in Models

Limit the scope of a function to a model.

Diagnostics Using a Client-Server Architecture

Create a diagnostic service with functions where callers pass an error code.

Featured Examples