Main Content

getGlobalArg

Get object definition of global variable in C Caller block

Since R2020b

Description

GlobalArg = PortSpecObj.getGlobalArg(globalVariableName), where PortSpecObj is an object of class FunctionPortSpecification, and creates a FunctionArgument object for the specified global argument.

example

Examples

collapse all

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

Obtain a FunctionPortSpecification object from the C Caller block (indicated as gcb) in your model using get_param function. For example, select the block in your model canvas and enter the following command at the command line.

myFunctionPortSpecObject = get_param(gcb, 'FunctionPortSpecification')

Query and create a FunctionArgument object for the global argument for the global variable myGlobalVarPort. Change the global variable to the one you use in your model.

 myGlobalVariable = myFunctionPortSpecObject.getGlobalArg('myGlobalVarPort')
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