メインコンテンツ

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

getExpression

クラス: coder.descriptor.TypedRegion
名前空間: coder.descriptor

Return code expression of data element

R2025a 以降

構文

expr = getExpression(implementation,noThrow)

説明

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

入力引数

すべて展開する

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.

データ型: logical

Output Arguments

すべて展開する

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

データ型: char

すべて展開する

  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'

バージョン履歴

R2025a で導入