Documentation

Function Caller

Call Simulink or exported Stateflow function

  • Library:
  • User-Defined Functions

Description

A Function Caller block calls and executes a function defined with a Simulink® Function block or an exported Stateflow® function. Using Function Caller blocks, you can call a function from anywhere in a model or chart hierarchy.

Ports

Input

expand all

Input signal for an input argument that is sent to the function.

The function prototype determines the number and name of input ports that appear on the Function Caller block. Connect signal lines to the input ports to send data to a function through the function input arguments.

For example, y = myfunction(u) creates one input port (u) on the Function Caller block.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Output

expand all

Output signal for an output argument that the function returns.

The function prototype determines the number and name of output ports that appear on the Function Caller block. Connect signal lines to the output ports to receive data from a function through the function output arguments.

For example, y = myfunction(u) creates one output port (y) on the Function Caller block.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Parameters

expand all

Specify the function interface between a Function Caller block and a Simulink function. A Simulink function can be a Simulink Function block, an exported Stateflow graphical function, or an exported Stateflow MATLAB® function. For a call to a Simulink Function block:

  • Function call argument names must match the function arguments.

  • Function names, input arguments, and output arguments must be valid MATLAB identifiers.

Programmatic Use

Block Parameter: FunctionPrototype
Type: character vector
Values: 'y=f(u)' | '<function prototype>'
Default: 'y-f(u)'

Specify a comma-separated list of MATLAB expressions that combine data type, dimensions, and complexity (real or imaginary) for each input argument. For examples, see Argument Specification for Simulink Functions.

This specification must match the Simulink Function block data type specified with the Data type parameter of the Argument Inport block.

Programmatic Use

Block Parameter: 'InputArgumentSpecifications'
Type: character vector
Values: '' | '<MATLAB expression>'
Default: ''

Specify a comma-separated list of MATLAB expressions that combine data type, dimensions, and complexity (real or imaginary) for each output argument. For examples, see Argument Specification for Simulink Functions.

This specification must match the Simulink Function block data type specified with the Data type parameter of the Argument Outport Block.

Programmatic Use

Block Parameter: 'OutputArgumentSpecifications'
Type: character vector
Values: '' | '<MATLAB expression>'
Default: ''

Specify the time interval between function calls to a subsystem or model containing this Trigger block. If the actual calling rate for the subsystem or model differs from the time interval this parameter specifies, Simulink displays an error.

Settings

-1

Inherit time interval from the trigger signal.

Ts

Scalar where Ts is the time interval.

[Ts, To]

Vector where Ts is the time interval and To is the initial time offset.

Programmatic Use

Block parameter: SampleTime
Type: character vector
Value: '-1' | 'Ts'| '[Ts, To]'
Default: '-1'
Was this topic helpful?