Main Content

getGlobalArg

Get object definition of global variable in C Caller block

Since R2020b

Description

example

GlobalArg = PortSpecObj.getGlobalArg(globalVariableName), where PortSpecObj is an object of class FunctionPortSpecification, creates a FunctionArgument object for the specified global argument. To use global variables in a model that uses C Caller blocks, enable 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 or string scalar.

Data Types: char | string

Output Arguments

collapse all

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

Version History

Introduced in R2020b