Contenu principal

applyStereotype

R2026b

Apply stereotype to model element

Description

applyStereotype(element,stereotype) applies a stereotype to a model element if the stereotype is not already applied to a model element. Stereotypes can be applied to architecture, component, port, connector, interface, allocation, function model elements, action, parameter and flow. The function model element is only available in software architectures. The action, parameter and flow elements are only available in activity diagram.

example

Examples

collapse all

Create a model with a component called Component.

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");
comp = addComponent(arch,"Component");

Create a profile with a stereotype and properties, open the Profile Editor, then apply the profile to the model.

profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");
latencybase = profile.addStereotype("LatencyBase");
latencybase.addProperty("latency",Type="double");
latencybase.addProperty("dataRate",Type="double",DefaultValue="10");
systemcomposer.profile.editor(profile)
model.applyProfile("LatencyProfile");

Apply the stereotype to the component and get the stereotypes on the component.

comp.applyStereotype("LatencyProfile.LatencyBase");
stereotypes = getStereotypes(comp)
stereotypes =

  1×1 cell array

    {'LatencyProfile.LatencyBase'}

Input Arguments

collapse all

Name of the stereotype, specified as a character vector or string in the form "<profile>.<stereotype>". The profile must already be imported into the model.

Data Types: char | string

More About

collapse all

Version History

Introduced in R2019a