| Simulink® | ![]() |
| On this page… |
|---|
Creating a Function-Call Model |
Simulink® allows certain blocks, such as a Function-Call Generator or an appropriately configured custom S-function, to control execution of a referenced model during a time step, using a function-call signal. See Function-Call Subsystems for more information. A referenced model capable of being invoked in this way is called a function-call model.
To view a function-call model demo, select Simulink > Modeling Features > Model Reference > Model Reference Function-Call from the Demos pane of the MATLAB® Help Browser or execute sldemo_mdlref_fcncall at the MATLAB command line.
To create a function-call model:
Insert a Trigger block at the root level of the model.
Set the Trigger block's Trigger type parameter to function-call.
Create and connect any other blocks required to implement the model.

Ensure that the model satisfies the conditions imposed on function-call models. See Function-Call Model Requirements for details.
You can now simulate the function-call model either by itself or by running a model that references the function-call model directly or indirectly.
To create a reference to a function-call model:
Create a Model block in the referencing model that references the function-call model. See Creating a Model Reference for details.
The top of the Model block displays a function-call port corresponding to the function-call trigger port in the function-call model.

Connect a Stateflow® chart, Function-Call Generator block, or other function-call-generating block to the Model block's function-call port. The signal connected to the port must be scalar.
Connect the Model blocks inputs and outputs if any to the appropriate blocks in the parent model.

Create and connect any other blocks required to implement the parent model.
Ensure that the referencing model satisfies the conditions for a model to reference other models. See Simulink® Model Referencing Requirements and Simulink® Model Referencing Limitations for details.
You can now simulate the model that references the function-call model.
To be a function-call model, a referenced model must meet the following requirements in addition to the requirements that every referenced model must meet.
A function-call model cannot have an outport that is driven only by Ground blocks, including hidden Ground blocks inserted by Simulink. To meet this requirement, do the following:
Insert a Signal Conversion block into the signal connected to the outport.
Enable the inserted block's Override optimizations and always copy signal option.
If the function-call model specifies a fixed-step solver and contains one or more blocks that use absolute or elapsed time, the referencing model must trigger the function-call model at the rate specified by the 'Fixed-step size' option on the Solver page of the Configuration Parameters dialog. Otherwise, the referencing model may trigger the function-call model at any rate.
A function-call model must not have direct internal connections between its root-level input and output ports. Simulink does not honor the None and Warning settings for the Invalid root Inport/Outport block connection diagnostic for a referenced function-call model. It reports all invalid root port connections as errors.
If the Sample time type is periodic, the sample-time period must not contain an offset.
The signal connected to a Model block's function-call port must be scalar.
![]() | Inheriting Sample Times | Simulink® Model Referencing Limitations | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |