Main Content

getGlobalArg

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

Description

example

GlobalArg= PortSpecObj.getGlobalArg(globalVariableName), wherePortSpecObjis an object of classFunctionPortSpecificationorSimulink.CodeImporter.SimulinkPortSpecification, creates aFunctionArgumentobject. To use global variables in a model that usesC Callerblocks, turn on theEnable custom code globals as function interfacesetting fromConfiguration Parameters>Simulation Target.

Examples

collapse all

Access the properties of a global variable used in aC Callerblock.

Create aFunctionPortSpecificationobject.

myFunctionPortSpecObject = get_param(gcb,'FunctionPortSpecification')

Query and create aFunctionArgumentobject 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 theC Callerblock, returned as aFunctionArgumentobject.

Version History

Introduced in R2020b