Main Content

Manage Function Call Outputs of a MATLAB Function Block

A function call output is an event on the output port of a MATLAB Function block that causes a Function-Call Subsystem or Stateflow® chart in the model to execute. See Using Function-Call Subsystems. You can add function call outputs to MATLAB Function blocks by using the Ports and Data Manager or the Model Explorer.

To use the Ports and Data Manager, double-click the MATLAB Function block to open the MATLAB Function Block Editor and click Edit Data. You can return to the block code by clicking the Go to Block Editor button Go to Block Editor button.

To use the Model Explorer, in the Modeling tab, in the Design section, click Model Explorer. In the Model Hierarchy pane, expand the model tree view and select the MATLAB Function block.

When using the Ports and Data Manager or the Model Explorer, you can create, manage, and delete function call outputs:

  • Modify the function call output properties by selecting the function call output in the left pane of the Ports and Data Manager or the Contents of pane in the Model Explorer.

  • Add a function call output by clicking Add > Function Call Output or the Add Function Call Output button Add Function Call Output button.

  • Delete a function call output by selecting a function call output and clicking Edit > Delete or the Delete button Delete button.

After creating a function call output, you need to call the function call output in the MATLAB Function block code.

Enable a Function-Call Subsystem with a MATLAB Function Block

This example uses a MATLAB Function block with a function call output to trigger a subsystem.

When the signal from the Pulse Generator block equals 1, the MATLAB Function block executes the function call output. The block then continues to execute the function call output at each major time step. Double-click the MATLAB Function block to open the code.

function y = fcn(u)
y = u;
if u == 1

The function-call subsystem allows the signal from the Sine Wave block to propagate when the function-call triggers. When the function call is not triggered, the subsystem outputs the last propagated value. Run the model and open the Scope block to see the outputs.

Considerations When Triggering Function-Call Subsystems

If a MATLAB Function block triggers a function-call subsystem and outputs a signal to the same function-call subsystem, the signal to the function-call subsystem is delayed by one time step compared to the function call. At the moment of the function call output, the function-call subsystem sees the previous MATLAB Function block output port value even if the output data has been updated within the block MATLAB® code.

Set Function Call Output Properties

After clicking the output function call you want to modify in the Ports and Data Manager or the Model Explorer, you can set the following properties.


Specifies the name of the function call output, following the naming conventions used in MATLAB.


Specifies the index of the port associated with the function call output. Function call output ports are numbered sequentially after output ports.


Specifies the description of the function call output.

Document link

Specifies the link to documentation for the function call output. You can enter a URL address or a MATLAB command that displays documentation, such as an HTML file or text in the MATLAB Command Window. When you click the Document link link, the MATLAB Function block evaluates the link and displays the documentation.

See Also

Related Examples

More About