Main Content

exist

类: coder.dictionary.Section
命名空间: coder.dictionary

确定代码定义是否存在于 Embedded Coder 字典分区中

自 R2019b 起

语法

tf = exist(sectionObj,defName)

说明

如果由 sectionObj 表示的 Embedded Coder 字典分区包含名为 defName 的定义,则 tf = exist(sectionObj,defName) 返回 true

输入参数

全部展开

Embedded Coder 字典中的分区,指定为 coder.dictionary.Section 对象。

Embedded Coder 字典定义的名称,指定为字符向量或字符串标量。

示例: 'StorageClass2'

输出参量

全部展开

true 或 false 结果,以 logical 数据类型的 10 形式返回。

示例

全部展开

打开模型 RollAxisAutopilot,并使用 coder.Dictionary 对象表示 Embedded Coder 字典。使用此对象可以访问字典的存储类分区,其中包含存储类定义。

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

创建一个 coder.dictionary.Section 对象,它表示 Embedded Coder 字典的存储类分区。

storageClassesSect = getSection(coderDictionary, 'StorageClasses');

检查存储类分区是否包含示例存储类 SignalStruct

exist(storageClassesSect,'SignalStruct')
ans =

  logical

   1

删除该存储类,然后查看定义是否仍存在。

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

  logical

   0

版本历史记录

在 R2019b 中推出