Main Content

addComponent

Add components to architecture

Description

components = addComponent(arch,compNames) adds a set of components specified by the names compNames.

To remove a component, use the destroy function.

example

components = addComponent(arch,compNames,stereotypes) applies stereotypes specified in stereotypes to the new components.

components = addComponent(___,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 the root architecture, and create components. Arrange the layout to view both components.

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");
names = ["Component1","Component2"];
comps = addComponent(arch,names);
Simulink.BlockDiagram.arrangeSystem("archModel");

Input Arguments

collapse all

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

Name of components, specified as a cell array of character vectors or an array of strings. The length of compNames must be the same as stereotypes.

Data Types: char | string

Stereotypes to apply to components, specified as a cell array of character vectors or an array of strings. Each element is the qualified stereotype name for the corresponding component in the form "<profile>.<stereotype>".

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 = addComponent(arch,compNames,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

Created components, returned as an array of systemcomposer.arch.Component objects.

More About

collapse all

Version History

Introduced in R2019a