Main Content

Function Element Call

Specify function call to be issued via invoking function port

  • Library:
  • Simulink / Ports & Subsystems

Description

The Function Element Call block allows a Function Caller block in a referenced model to call a Simulink® function in another referenced model. The Function Element Call block, when placed at the root level of a model referenced by a Model block, creates an invoking function port in the Model block. When the invoking function port is connected to an exporting function port of another Model block, a Function Caller block in the Model block can issue function calls to Simulink functions in that other Model block and receive return values through the respective function ports of the Model blocks.

Simulink canvas showing 2 referenced models with function ports and a line connecting them.

Simulink canvas showing Function Element Call block and Function-Call Subsystem block, with a Function Caller block inside the subsystem.

By using multiple Function Element Call blocks, multiple Function Caller blocks in a referenced model can issue function calls through a single invoking function port. All Function Element Call blocks that use the same port share a dialog box. A model can have more than one invoking function port.

A Function Element Call 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 Call block, a Function-Call Subsystem block should also be placed at the root level of the model, and a Function Caller block should be placed inside the subsystem, designating the function to call through the Function Element Call block.

Create Port and Related Blocks

When you insert an Function Element Call 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 Call 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 Call 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 Call 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, type fcn\?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 call through the port.

Use the function element name as the function name in the Function prototype parameter of the Function Caller block issuing function calls through the port, qualified by the port name. See Port name.

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.

Pencil button next to port name

Select a service interface from the Data type list or enter it as Bus: ServiceInterfaceName. The service interface name now appears in parentheses next to the port name.

Service interface name next to port name

You can associate a service interface definition only with the port as a whole, not with individual function elements within the port.

Parameters

expand all

Specify a port name that is not already in use by another port. The name appears as a port label on the parent Model block. The name also appears next to the block. Multiple blocks can access the same port.

Use the same port name to qualify, with dot notation, the function name in the Function prototype parameter of the Function Caller block issuing function calls through the port:

[OutputArg1,OutputArg2,...] = PortName.FunctionElementName(InputArg1,InputArg2,...)

Programmatic Use

Block Parameter: PortName
Type: character vector
Values: 'client' | '<port name>'
Default: 'client'

Specify the order in which the port that corresponds to the block appears on the parent Model block.

  • If you add a block that creates another port, the port number is the next available number.

  • Deleting all blocks associated with a port deletes the port. Other ports are renumbered so that they are sequential and do not skip any numbers.

  • Specifying a port number that exceeds the number of ports creates a port for that number and for any skipped sequential numbers.

Programmatic Use

Block Parameter: Port
Type: character vector
Values: real integer
Default: '1'

Specify the block background color. This specification sets the color of blocks associated with selected function elements, or of all blocks associated with the port if you do not select any function elements.

Programmatic Use

Block Parameter: BackgroundColor
Type: character vector
Values: 'black' | 'white | 'red' | 'green' | 'blue' | 'cyan' | 'magenta' | 'yellow' | 'gray' | 'lightBlue' | 'orange' | 'darkGreen' | '[r,g,b]' where r, g, and b, are the red, green, blue values of the color in the range 0.0 to 1.0
Default: 'black'

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | half | integer | single | string

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2022a