Function Element
Libraries:
Simulink /
Ports & Subsystems
Description
The Function Element block allows a Simulink® function in a referenced model to be called by a function caller in another referenced model. The Function Element block, when placed at the root level of a model referenced by a Model block, creates an exporting function port in the Model block. When the exporting function port is connected to an invoking function port of another Model block, a function caller in that other Model block can issue function calls and receive return values through the respective function ports of the Model blocks.
By using multiple Function Element blocks, multiple Simulink functions in a referenced model can be called through a single exporting function port. All Function Element blocks that use the same port share a dialog box. A model can have more than one exporting function port.
A Function Element block must be placed at the root level of model designated as an export-function model. See Export-Function Models Overview. For each Function Element block, a port-scoped Simulink Function block should also be placed at the root level of the model, defining the function to be called through the Function Element block.
Create Port and Related Blocks
When you insert an Function Element block, the block label populates with default values. The label consists of two interactive text fields: the port name and the function element name. To change the name of the port associated with the block, edit the first text field in the label by clicking the text.
To allow multiple functions to be called through a port, create a Function
Element block for each function that you want to include. In the block
dialog box, you can click the Add a new function
button. Alternatively, hold Ctrl while you
drag an existing Function Element block to a new location. Upon
releasing the pointer, select
Use Existing Port
.
If multiple blocks are associated with the same port and you change the name of the port, all blocks that share the port update to reflect the new port name.
To create a port, hold Ctrl while you drag an existing
Function Element block to a new location. Upon releasing the
pointer, select Create New Port
.
Modify Port Characteristics
In the block dialog box, you can:
Change port and function element names.
Reorder function elements by dragging an element into the list of elements.
Remove blocks associated with selected function elements by clicking the Remove blocks of selected function elements button
.
Use the Filter box to specify a search term to use for filtering a long list of function elements. Do not enclose the search term in quotation marks. The filter does a partial string search and supports regular expressions. To use a regular expression character as a literal, include an escape character (
\
). For example, to use a question mark, typefcn\?1
.
Specify Function Element Name
To change the name of the function element associated with the block, edit the second text field in the label by clicking the text.
All function element names associated with the port must be unique. Each function element name should match the function name of one of the Simulink Function blocks to be called through the port.
Specify Service Interface
To associate the port with a service interface authored in System Composer™, in the block dialog box, pause on the name of the port where it appears at the top of the list of function elements. Then, click the pencil button that appears next to the port name.
Select a service interface from the Data type list or enter
it as Bus:
. The
service interface name now appears in parentheses next to the port name.ServiceInterfaceName
You can associate a service interface definition only with the port as a whole, not with individual function elements within the port.
Parameters
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Extended Capabilities
Version History
Introduced in R2022a