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 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, Global or Parameter. If the custom code has a global variable, you can set the scope to Global to map the variable as a global argument. 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 Custom C Functions in Simulink Using C Caller Block.

openExample('simulink/ArithmeticOperationsUsingCCallerBlocksExample')
open_system('CCallerExample.slx')

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

 my_CCallerObj = get_param('CCallerExample/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