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 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 Ports & Data Manager. You can return to the block code by clicking the 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 input triggers:
Modify the input trigger properties by selecting the input trigger in the left pane of the Ports and Data Manager or the Contents of pane in the Model Explorer.
Add an input trigger by clicking Add > Trigger or the Add Trigger button .
Delete the input trigger by selecting the input trigger and clicking Edit > Delete or the Delete button .
After clicking the input trigger 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 input trigger, following the naming conventions used in MATLAB®.
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.
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.