Manage the Input Trigger of a MATLAB Function Block
An input trigger is an input that executes the MATLAB Function block when activated. See Using Triggered Subsystems. You can add one input trigger to each MATLAB Function block and configure the input trigger by using the Symbols pane and Property Inspector or the Model Explorer.
Create an Input Trigger
To create an input trigger, use the Symbols pane or the Model Explorer.
To use the Symbols pane:
Open the MATLAB Function Block Editor. In the Function tab, click Edit Data.
Click the Create Event button and select Add Trigger.
To delete the input trigger, right-click the input trigger name and select Delete.
To use the Model Explorer:
Open the Model Explorer. In the Modeling tab, in the Design section, click Model Explorer.
In the Model Hierarchy pane, select the MATLAB Function block.
Click Add > Trigger or the Add Trigger button .
To delete the input trigger, select the input trigger output and click Edit > Delete or the Delete button .
Enable a MATLAB Function Block with an Input Trigger
This example uses a MATLAB Function block that is controlled by an
either input trigger.
When the signal from the Square Wave Generator block rises or falls below
0, the MATLAB Function block executes. Double-click the MATLAB Function block to open the code.
function [y1,y2] = fcn(u)
y1 = u; y2 = u - 1;
The MATLAB Function block outputs the last propagated value until the block triggers again. Run the model and open the Scope block to see the outputs.
Set Input Trigger Properties
To adjust the input trigger properties, use the Symbols pane and Property Inspector or the Model Explorer.
To edit the properties by using the Symbols pane and Property Inspector, specify the input trigger and open the Property Inspector by using of one of these approaches:
In the Function tab, click Edit Data. In the Symbols pane, select the input trigger.
In the Symbols pane, right-click the input trigger name and click Inspect.
In the Modeling tab, in the Design Data section, click Property Inspector. In the Symbols pane, select the input trigger.
To edit the properties by using the Model Explorer, click the input trigger.
You can modify the following properties.
Specifies the name of the input trigger. Use the naming conventions used in MATLAB®. You can only set this property in the Symbols pane or Model Explorer.
Specifies the index of the port associated with the input trigger. The property is
read-only. Because you can only add one trigger to a MATLAB Function block,
this property is always
Specifies the type of event that triggers the MATLAB Function block. You can select one of the following types:
|The trigger signal executes the MATLAB Function block when the signal rises from a negative or zero value to a positive value or from a negative value to zero.
|The trigger signal executes the MATLAB Function block when the signal falls from a positive or zero value to a negative value or from a positive value to zero..
|The trigger signal executes the MATLAB Function block when the
control signal is either
|A trigger signal from a block that outputs function-call events executes the MATLAB Function block.
Specifies the description of the input trigger.
Specifies the link to the documentation for the input trigger. 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.