主要内容

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

addVariantComponent

为架构添加变体组件

说明

variants = addVariantComponent(arch,variantComponents) 添加一组由名称数组指定的变体组件。

要移除变体组件,请使用 destroy 函数。

示例

variants = addVariantComponent(___,Position=coordinatesVector) 添加了一组变体组件,并通过定义每个组件在画布上的左上角和右下角坐标(以 1-by-4 数值数组的形式)来指定其位置。

示例

全部折叠

创建一个模型,获取其根架构,并创建两个变体组件。

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");
names = ["Component1","Component2"];
variantComps = addVariantComponent(arch,names)
variantComps=1×2 VariantComponent array with properties:
    Architecture
    Name
    Parent
    Ports
    OwnedPorts
    OwnedArchitecture
    Parameters
    Position
    Model
    SimulinkHandle
    SimulinkModelHandle
    UUID
    ExternalUID

输入参数

全部折叠

架构,指定为 systemcomposer.arch.Architecture 对象。

变体组件的名称,指定为字符向量元胞数组或字符串数组。

数据类型: char | string

组件在画布上的位置,指定为坐标向量,单位为像素 [left top right bottom]

每个向量指定组件左上角和右下角的位置,以 1-by-4 数值数组的形式给出。该数组通过其 xy 坐标表示左上角,随后是右下角的 xy 坐标。

在添加多个组件时,可以指定一个大小为 N-by-4 的矩阵,其中 N 是要添加的组件数。

数据类型: numeric

输出参量

全部折叠

变体组件,以 systemcomposer.arch.VariantComponent 对象数组的形式返回。该数组的大小与 variantComponents 相同。

详细信息

全部折叠

版本历史记录

在 R2019a 中推出