主要内容

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

getPortElement

按名称查找端口元素

自 R2026a 起

    说明

    portElement = getPortElement(name) 根据 name 指定的部分名称查找端口元素或子端口元素。

    示例

    示例

    全部折叠

    创建模型并获取根架构。

    model = systemcomposer.createModel("archModel");
    systemcomposer.openModel("archModel");
    rootArch = get(model,"Architecture");

    添加一个组件,并为组件添加一个端口。

    newComponent = addComponent(rootArch,"newComponent");
    newPort = addPort(newComponent.Architecture,"newPort","in");

    添加一个包含一个数据元素的第一个数据接口。

    newInterface = addInterface(model.InterfaceDictionary,"newInterface");
    newElement = addElement(newInterface,"newElement",DataType="double");

    添加第二个数据接口,并包含第二个数据元素。

    newInterface2 = addInterface(model.InterfaceDictionary,"newInterface2");
    newElement2 = addElement(newInterface2,"newElement2",DataType="double");

    使用第二个数据接口输入第一个数据元素。

    newElement.setType(newInterface2)

    在该端口上设置第一个接口。

    setInterface(newPort,newInterface)

    从端口元素访问数据元素。

    portElement = getPortElement(newPort,'newElement')
    portElement = 
    
      PortElement with properties:
    
                       Name: 'newElement'
                     Parent: [1×1 systemcomposer.arch.ArchitecturePort]
                SubElements: [1×1 systemcomposer.arch.PortElement]
           InterfaceElement: [1×1 systemcomposer.interface.DataElement]
                      Model: [1×1 systemcomposer.arch.Model]
             SimulinkHandle: -1
        SimulinkModelHandle: 149.0002
                       UUID: '40b38418-76b2-4a96-9da7-d6c6f237cf56'
                ExternalUID: ''

    输入参数

    全部折叠

    端口元素的部分名称,指定为字符向量或字符串。

    如果将 name 指定为 "a.b",则 getPortElement 函数会查找端口元素 "a",然后在 "a" 内部查找子端口元素 "b"

    示例: "a.b"

    数据类型: char | string

    输出参量

    全部折叠

    端口元素,以 systemcomposer.arch.PortElement 对象形式返回。

    详细信息

    全部折叠

    版本历史记录

    在 R2026a 中推出