Main Content

getExpression

Class: coder.descriptor.TypedRegion
Namespace: coder.descriptor

Return code expression of data element

Since R2025a

Syntax

expr = getExpression(implementation,noThrow)

Description

expr = getExpression(implementation,noThrow) returns a C/C++ expression that enables you to access the data element in the generated code.

Input Arguments

expand all

Description of implementation of data in the generated code, specified as a coder.descriptor.TypedRegion object.

Flag to throw an error if the expression is not usable in arbitrary code. The elements of the expression are usable if all members of the TypedRegion object exist in the generated code and are not private or protected class members.

  • false or 0 — Throw an error.

  • true or 1 — Do not throw an error.

Data Types: logical

Output Arguments

expand all

C/C++ expression to access the data element, relative to the topmost element in the TypedRegion object, returned as a character vector.

Data Types: char

Examples

expand all

  1. Open the model.

    openExample('CustomCodeComments')
  2. Build the model.

    slbuild('CustomCodeComments')

  3. Create a coder.codedescriptor.CodeDescriptor object for the required model.

    codeDescObj = coder.getCodeDescriptor('CustomCodeComments')
    

  4. Return properties of the Inports data interface type in the generated code.

    dataInterfaces = getDataInterfaces(codeDescObj, 'Inports')
  5. Return properties of the code representation of the first Inport block.

    implementation = dataInterfaces(1).Implementation
  6. Return the C expression for accessing the first Inport block in the generated code.

    getExpression(implementation)
      ans =
        'rtU.In1'

Version History

Introduced in R2025a