Main Content

exist

Class: coder.dictionary.Section
Namespace: coder.dictionary

Determine if code definition exists in Embedded Coder Dictionary section

Since R2019b

Syntax

tf = exist(sectionObj,defName)

Description

tf = exist(sectionObj,defName) returns true if the Embedded Coder Dictionary section represented by sectionObj contains a definition with the name defName.

Input Arguments

expand all

Section in the Embedded Coder Dictionary, specified as a coder.dictionary.Section object.

Name of Embedded Coder Dictionary definition, specified as a character vector or string scalar.

Example: 'StorageClass2'

Output Arguments

expand all

True or false result, returned as a 1 or 0 of data type logical.

Examples

expand all

Open the model RollAxisAutopilot and represent the Embedded Coder Dictionary by using a coder.Dictionary object. Use this object to access the Storage Classes section of the dictionary, which contains the storage class definitions.

openExample('RollAxisAutopilot')
coderDictionary = coder.dictionary.open('RollAxisAutopilot');

Create a coder.dictionary.Section object that represents the Storage Classes section of the Embedded Coder Dictionary.

storageClassesSect = getSection(coderDictionary, 'StorageClasses');

Check if the Storage Classes section contains the example storage class SignalStruct.

exist(storageClassesSect,'SignalStruct')
ans =

  logical

   1

Remove the storage class, and then see whether the definition still exists.

deleteEntry(storageClassesSect,'SignalStruct');
exist(storageClassesSect,'SignalStruct')
ans =

  logical

   0

Version History

Introduced in R2019b