Main Content

addVariantComponent

Add variant components to architecture

Description

variants = addVariantComponent(arch,variantComponents) adds a set of variant components specified by the array of names.

To remove a variant component, use the destroy function.

example

variants = addVariantComponent(___,Position=coordinatesVector) adds a set of variant components, and specifies their positions by defining the coordinates of the top-left and bottom-right corners of each component on the canvas, in the form of a 1-by-4 numeric array.

Examples

collapse all

Create a model, get its root architecture, and create two variant components.

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

Input Arguments

collapse all

Architecture, specified as a systemcomposer.arch.Architecture object.

Names of variant components, specified as a cell array of character vectors or an array of strings.

Data Types: char | string

Position of component on canvas, specified as a vector of coordinates, in pixels [left top right bottom].

Each vector specifies the location of the top-left corner and bottom-right corner of the component, specified as a 1-by-4 numeric array. The array denotes the top-left corner in terms of its x and y coordinates followed by the x and y coordinates of the bottom-right corner.

When adding more than one component, you can specify a matrix of size N-by-4, where N is the number of components being added.

Data Types: numeric

Output Arguments

collapse all

Variant components, returned as an array of systemcomposer.arch.VariantComponent objects. This array is the same size as variantComponents.

More About

collapse all

Version History

Introduced in R2019a