Main Content

本页采用了机器翻译。点击此处可查看英文原文。

updateAttribute

类: slreq.LinkSet
命名空间: slreq

更新链接集自定义属性的信息

自 R2020b 起

语法

updateAttribute(myLinkSet,atrb,Name,Value)

说明

updateAttribute(myLinkSet,atrb,Name,Value) 使用链接集 myLinkSet 中的名称-值对 NameValue 指定的属性来更新 atrb 指定的自定义属性。

输入参数

全部展开

链接集,指定为 slreq.LinkSet 对象。

自定义属性名称,指定为字符数组。

名称-值参数

将可选的参量对组指定为 Name1=Value1,...,NameN=ValueN,其中 Name 是参量名称,Value 是对应的值。名称-值参量必须出现在其他参量后,但参量对组的顺序无关紧要。

在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name 引起来

示例: 'Description','My new description.'

自定义属性描述,指定为由 'Description' 和字符数组组成的逗号分隔的对。

示例: 'Description','My new description.'

Combobox 列表选项,指定为由 'List' 和元胞数组组成的逗号分隔的对。仅当 'Unset' 是第一个条目时,选项列表才有效。'Unset' 表示用户尚未从组合框中选择选项。如果列表不是以 'Unset' 开头,它将自动附加为第一个条目。

示例: 'List',{'Unset','A','B','C'}

注意

仅当您要更新的自定义属性的 Type属性为 Combobox 时,才可以使用此名称-值对。

示例

全部展开

此示例显示如何更新链接集的自定义属性信息。

加载描述巡航控制系统的crs_req需求文件。在文件中找到链接集并将其分配给变量。

slreq.load('crs_req');
ls = slreq.find('Type','LinkSet');

更新 Edit 自定义属性

向链接集添加具有描述的Edit自定义属性。使用 inspectAttribute 获取属性信息。

addAttribute(ls,'MyEditAttribute','Edit','Description','Original attribute.');
inspectAttribute(ls,'MyEditAttribute')
ans = struct with fields:
           name: 'MyEditAttribute'
           type: Edit
    description: 'Original attribute.'

使用新的描述更新自定义属性。通过使用 inspectAttribute 获取属性信息来确认更改。

updateAttribute(ls,'MyEditAttribute','Description','Updated attribute.');
inspectAttribute(ls,'MyEditAttribute')
ans = struct with fields:
           name: 'MyEditAttribute'
           type: Edit
    description: 'Updated attribute.'

更新 Combobox 自定义属性

向链接集添加一个带有选项列表的 Combobox 自定义属性。使用 inspectAttribute 获取属性信息。

addAttribute(ls,'MyCombobox','Combobox','List',{'Unset','A','B','C'});
inspectAttribute(ls,'MyCombobox')
ans = struct with fields:
           name: 'MyCombobox'
           type: Combobox
    description: ''
           list: {'Unset'  'A'  'B'  'C'}

使用新的选项列表更新自定义属性。通过使用 inspectAttribute 获取属性信息来确认更改。

updateAttribute(ls,'MyCombobox','List',{'Unset','1','2','3'});
inspectAttribute(ls,'MyCombobox')
ans = struct with fields:
           name: 'MyCombobox'
           type: Combobox
    description: ''
           list: {'Unset'  '1'  '2'  '3'}

使用新的选项列表和新的描述更新自定义属性。通过使用 inspectAttribute 获取属性信息来确认更改。

updateAttribute(ls,'MyCombobox','List',{'Unset','A1','B2','B3'},'Description',...
    'Updated attribute with new options.');
inspectAttribute(ls,'MyCombobox')
ans = struct with fields:
           name: 'MyCombobox'
           type: Combobox
    description: 'Updated attribute with new options.'
           list: {'Unset'  'A1'  'B2'  'B3'}

清理

清除打开的需求集和链接集,并关闭打开的模型而不保存更改。

slreq.clear;
bdclose all;

版本历史记录

在 R2020b 中推出