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(___,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments in previous syntaxes.

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

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: comps = addVariantComponent(arch,variantComponents,Position=[100 100 200 300])

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