A Function-Call Subsystem block is a conditionally executed subsystem that runs each time the control signal has a function-call event. A Stateflow® chart, Function-Call Generator block, or an S-function block can provide function call events.
A function-call subsystem is analogous to a function in a procedural programming language. Invoking a function-call subsystem executes the output methods of the blocks within the subsystem in sorted order. For an explanation of Function-Call Subsystem blocks parameters, see Subsystem, Atomic Subsystem, Nonvirtual Subsystem, CodeReuse Subsystem
To create a function-call subsystem:
Add an Function-Call Subsystem block to your model.
Copy a block from the Simulink Ports & Subsystems library to your model.
Click the model diagram, start typing
and then select Function-Call Subsystem.
Set how subsystem states are handled when executed.
Open the subsystem block, and then open the block parameters dialog box for the Trigger block. From the States when enabling drop-down list, select:
held — States maintain
their most recent values.
reset — States set
to their initial conditions.
inherit — Use the
held or reset setting from the parent subsystem initiating the function-call.
For nested subsystems whose Function-Call Subsystem blocks have different parameter settings, the settings for the child subsystem override the settings inherited from the parent subsystem.
Attach a function-call initiator to the function-call input port.
If you attach an Inport block, open the block, select the Signal Attributes pane, and then select the Output function call check box.
You can also create a function-call subsystem from scratch. First, add a
Subsystem block in your model, and then add a Trigger block
in the subsystem. Next, open the Trigger block dialog box and set the
Trigger type to
Configure a Function-Call Subsystem block by
setting the Sample time type of its Trigger port
A triggered function-call subsystem can execute zero, one, or multiple times during a time step.
If a function-call subsystem is triggered by a root Inport block
with a discrete sample time, multiple function-calls during a time
step are not allowed. To allow multiple function-calls, set Sample
You must set the sample time for all the blocks in a triggered
function-call subsystem to inherited (
A periodic function-call subsystem executes once during a time step and must receive periodic function-calls. If the function-calls are aperiodic, the simulation stops and an error message is displayed.
You can specify a noninherited sample time or inherited (
sample time. All blocks that specify a noninherited sample time must
specify the same sample time. For example, if one block specifies
the sample time, all other blocks must specify a sample time of
If function-calls are at a rate that differs from the sample time
specified by the blocks in the subsystem, the simulation stops and
an error message is displayed.
During range checking, the minimum and maximum parameter settings are back-propagated to the actual source port of the function-call subsystem, even when the function-call subsystem is not enabled.
To prevent this back propagation:
Add a Signal Conversion block and a Signal Specification block after the source port.
Set the Output of the Signal
Conversion block to
Specify the minimum and maximum values for the Signal Specification block instead of specifying them on the source port.