Main Content

FunctionArgument

Specify parameters of C Caller block inputs and outputs

Description

Use the FunctionArgument object to customize the types, scopes, and names of inputs and outputs for a C Caller block.

Use this object to set the InputArguments, ReturnArgument, and GlobalArguments parameters of the FunctionPortSpecification object for a C Caller block or a Simulink.CodeImporter.SimulinkPortSpecification object for the Simulink® Code Importer.

Properties

expand all

This property is read-only.

Name of the variable in the source code, specified as a string or a character vector.

Data Types: char | string

This property is read-only.

Port number of the argument.

Data Types: uint32

Size of the argument, specified as a string or a character vector.

Example: [3]

Data Types: char | string

Data type of the argument, specified as a string or a character vector.

Example: double

Data Types: char | string

Label of the argument on the C Caller block, specified as a string or a character vector.

Example: MyArg

Data Types: char | string

Mapping of argument to a Simulink port type, specified as "Input", "Output", "InputOutput", or "Parameter". If the argument has a const modifier, you can set "Input" or "Parameter". Otherwise, you can change an output argument to "Input", "InputOutput", or "Parameter".

Data Types: char | string

Examples

collapse all

Open the model from the example Call C Functions Using C Caller Block.

openExample('simulink_features/CallCFunctionsUsingCCallerBlockExample')
open_system('slexCCallerExample.slx')

Get a C Caller block configuration object using the model slexCCallerExample.

my_CCallerObj = get_param("slexCCallerExample/C Caller",...
                          "FunctionPortSpecification")
my_CCallerObj = 

  FunctionPortSpecification with properties:

        CPrototype:  'real_T add(real_T u1, real_T u2);'
    InputArguments:  [1×2 Simulink.CustomCode.FunctionArgument]
    ReturnArgument:  [1×1 Simulink.CustomCode.FunctionArgument]
    GlobalArguments: [1×0 Simulink.CustomCode.FunctionArgument]

Get the FunctionArgument object for the first input port.

inargone = my_CCallerObj.InputArguments(1)
inargone = 

  FunctionArgument with properties:

          Name: 'u1'
    PortNumber: 1
          Size: '1'
          Type: 'double'
         Label: 'u1'
         Scope: 'Input'

Change the label for the first input port.

inargone.Label = "inputport1"
inargone = 

  FunctionArgument with properties:

          Name: 'u1'
    PortNumber: 1
          Size: '1'
          Type: 'double'
         Label: 'inputport1'
         Scope: 'Input'

Version History

Introduced in R2019b