Main Content

getGlobalArg

Get an object definition of a global variable in a C Caller block

Description

example

GlobalArg = getGlobalArg(globalVariableName) creates a FunctionArgument object. To use global variables in a model that uses C Caller blocks, turn on the Enable custom code globals as function interface setting from Configuration Parameters > Simulation Target.

Examples

collapse all

Access the properties of a global variable used in a C Caller block.

Create a FunctionPortSpecification object.

myFunctionPortSpecObject = get_param(gcb, 'FunctionPortSpecification')

Query and create a FunctionArgument object for the global argument.

myGlobalVariable = myFunctionPortSpecObject.getGlobalArg('myGlobalVariableName')
myGlobalVariable = 

  FunctionArgument with properties:

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

Input Arguments

collapse all

Name of global variable, specified as a character vector.

Data Types: char

Output Arguments

collapse all

Global argument object associated with the C Caller block, returned as a FunctionArgument object.

Introduced in R2020b