Main Content


Common base class for all components in architecture model


A systemcomposer.arch.BaseComponent cannot be constructed. Either create a systemcomposer.arch.Component or systemcomposer.arch.VariantComponent. This class is derived from systemcomposer.arch.Element.


expand all

Name of component, specified as a character vector.

Example: 'newComponent'

Data Types: char

Architecture that defines component structure, specified as a systemcomposer.arch.Architecture object. For a component that references a different architecture model, this property returns a handle to the root architecture of that model. For variant components, the architecture is that of the active variant.

Architecture that owns component, specified as a systemcomposer.arch.Architecture object.

Input and output ports of component, specified as a systemcomposer.arch.ComponentPort object.

Architecture owned by component, specified as a systemcomposer.arch.Architecture object.

Component ports, specified as an array of systemcomposer.arch.ComponentPort objects. For reference components, this property is empty.

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

Data Types: double

Universal unique identifier for model component, specified as a character vector.

Example: '91d5de2c-b14c-4c76-a5d6-5dd0037c52df'

Data Types: char

Unique external identifier, specified as a character vector. The external ID is preserved over the lifespan of the element and through all operations that preserve the UUID.

Data Types: char

Parent model of component, specified as a systemcomposer.arch.Model object.

Simulink handle for component, specified as a double. This property is necessary for several Simulink related work flows and for using Simulink Requirement APIs.

Example: handle = get(object,'SimulinkHandle')

Data Types: double

Simulink handle to parent model of component, specified as a double. This property is necessary for several Simulink related work flows and for using Simulink Requirement APIs.

Example: handle = get(object,'SimulinkModelHandle')

Data Types: double

Object Functions

getPropertyGet property value corresponding to stereotype applied to element
setPropertySet property value corresponding to stereotype applied to element
getPropertyValueGet value of architecture property
getEvaluatedPropertyValueGet evaluated value of property from component
getStereotypePropertiesGet stereotype property names on element
applyStereotypeApply stereotype to architecture model element
getStereotypesGet stereotypes applied on element of architecture model
removeStereotypeRemove stereotype from model element
isReferenceFind if component is reference to another model
connectCreate architecture model connections
getPortGet port from component
destroyRemove model element


collapse all

This example shows how to build an architecture model using the System Composer™ API.

Prepare Workspace

Clear all profiles from the workspace.


Build a Model

To build a model, add a data dictionary with interfaces and interface elements, then add components, ports, and connections. After the model is built, you can create custom views to focus on a specific concern. You can also query the model to collect different model elements according to criteria you specify.

Add Components, Ports, and Connections

Create the model and extract its architecture.

model = systemcomposer.createModel('mobileRobotAPI');
arch = model.Architecture;

Create data dictionary and add an interface. Link the interface to the model.

dictionary = systemcomposer.createDictionary('SensorInterfaces.sldd');
interface = addInterface(dictionary,'GPSInterface');

Add components, ports, and connections. Set the interface to ports, which you will connect later.

components = addComponent(arch,{'Sensor','Planning','Motion'});
sensorPorts = addPort(components(1).Architecture,{'MotionData','SensorData'},{'in','out'});

planningPorts = addPort(components(2).Architecture,{'Command','SensorData1','MotionCommand'},{'in','in','out'});

motionPorts = addPort(components(3).Architecture,{'MotionCommand','MotionData'},{'in','out'});

Connect components with an interface rule. This rule connects ports on components that share the same interface.

c_sensorData = connect(arch,components(1),components(2),'Rule','interfaces');
c_motionData = connect(arch,components(3),components(1));
c_motionCommand = connect(arch,components(2),components(3));

Save Data Dictionary

Save the changes to the data dictionary.; 

Add and Connect an Architecture Port

Add an architecture port on the architecture.

archPort = addPort(arch,'Command','in');

The connect command requires a component port as argument. Obtain the component port and connect:

compPort = getPort(components(2),'Command');
c_Command = connect(archPort,compPort);

Save the model.


Open the model


Arrange the layout by pressıng Ctrl+Shift+A or using the following command:


Create and Apply Profile and Stereotypes

Profiles are xml files that can be applied to any model. You can add stereotypes with properties to profiles and then populate the properties with specific values. Along with System Composer’s built-in analysis capabilities, stereotypes can guide optimizations of your system for performance, cost, and reliability.

Create a Profile and Add Stereotypes

Create a profile.

profile = systemcomposer.createProfile('GeneralProfile');

Create a stereotype that applies to all element types:

elemSType = addStereotype(profile,'projectElement');

Create stereotypes for different types of components. These types are dictated by design needs and are up to your discretion:

pCompSType = addStereotype(profile,'physicalComponent','AppliesTo','Component');
sCompSType = addStereotype(profile,'softwareComponent','AppliesTo','Component');

Create a stereotype for connections:

sConnSType = addStereotype(profile,'standardConn','AppliesTo','Connector');

Add Properties

Add properties to stereotypes. You can use properties to capture metadata for model elements and analyze non-functional requirements. These properties are added to all elements to which the stereotype is applied, in any model that imports the profile.


Save the Profile


Apply Profile to Model

Apply the profile to the model:


Apply stereotypes to components. Some components are physical components, and others are software components.


Apply the connector stereotype to all connections:


Apply the general element stereotype to all connectors and ports:


Set properties for each component:

setProperty(components(1),'GeneralProfile.projectElement.Description','''Central unit for all sensors''');
setProperty(components(2),'GeneralProfile.projectElement.Description','''Planning computer''');
setProperty(components(3),'GeneralProfile.projectElement.Description','''Motor and motor controller''');

Set the properties of connections to be identical:

connections = [c_sensorData c_motionData c_motionCommand  c_Command];
for k = 1:length(connections)

Add Hierarchy

Add two components named Controller and Scope inside the Motion component. Define the ports. Connect them to the architecture and to each other, applying a connector stereotype. Hierarchy in an architecture diagram creates an additional level of detail that specifies how components behave internally.

motionArch = components(3).Architecture;
motion = motionArch.addComponent({'Controller','Scope'});

controllerPorts = addPort(motion(1).Architecture,{'controlIn','controlOut'},{'in','out'});
controllerCompPortIn = motion(1).getPort('controlIn');
controllerCompPortOut = motion(1).getPort('controlOut');

scopePorts = addPort(motion(2).Architecture,{'scopeIn','scopeOut'},{'in','out'});
scopeCompPortIn = motion(2).getPort('scopeIn');
scopeCompPortOut = motion(2).getPort('scopeOut');

c_planningController = connect(motionPorts(1),controllerCompPortIn);
c_planningScope = connect(scopeCompPortOut,motionPorts(2));
c_planningConnect = connect(controllerCompPortOut,scopeCompPortIn,'GeneralProfile.standardConn');

Save the model.


Arrange the layout by pressıng Ctrl+Shift+A or using the following command:


Create a Model Reference

Model references are useful to organize large models hierarchically and allow you to define architectures or behaviors once and reuse it. When a component references another model, any existing ports on the component are removed and ports that exist on the referenced model will appear on the component.

Create a new System Composer model. Convert the Sensor component into a reference component to reference the new model. To add additional ports on the Sensor component, you must update the referenced model mobileSensor.

newModel = systemcomposer.createModel('mobileSensor');
newArch = newModel.Architecture;
newComponents = addComponent(newArch,'ElectricSensor');


Apply a stereotype to the linked reference model's architecture and component.

referenceModel = get_param('mobileSensor','SystemComposerModel');

Add ports and connections to the reference component.

sensorPorts = addPort(components(1).Architecture,{'MotionData','SensorData'},{'in','out'});

Save the models.


Make a Variant Component

You can convert the Planning component into a variant component using the makeVariant function. The original component is embedded within a variant component as one of the available variant choices. You can design other variant choices within the variant component and toggle the active choice. Variant components allow you to choose behaviorial designs programmatically in an architecture model to perform trade studies and analysis.

[variantComp,choice1] = makeVariant(components(2));

Add an additional variant choice named PlanningAlt. The second argument defines the name, and the third argument defines the label. The label identifies the choice. The active choice is controlled by the label.

choice2 = addChoice(variantComp,{'PlanningAlt'},{'PlanningAlt'});

Create the necessary ports on PlanningAlt.

planningAltPorts = addPort(choice2.Architecture,{'Command','SensorData1','MotionCommand'},{'in','in','out'});

Make PlanningAlt the active variant.


Arrange the layout by pressıng Ctrl+Shift+A or using the following command:


Save the model.


Clean Up

Uncomment the following code and run to clean up the artifacts created by this example:

% bdclose('mobileRobotAPI')
% bdclose('mobileSensor')
% systemcomposer.profile.Profile.closeAll
% delete('Profile.xml')
% delete('SensorInterfaces.sldd')

More About

expand all

Introduced in R2019b