To build a System Composer™ model, you can import information about components, ports, and connections in a predefined format using MATLAB® table objects. You can extend these tables and add information like applied stereotypes, property values, linked model references, variant components, interfaces, and requirement links.
Similarly, you can export information about components, hierarchy of components, ports on components, connections between components, linked model references, variants, stereotypes on elements, interfaces, and requirement links.
The minimum required structure for a System Composer model consists of these sets of information:
To import additional elements, you need to add columns to the tables and add specific values for these elements.
The information about components is passed as values in a MATLAB table against predefined column names, where:
Name is the component name.
ID is a user-defined ID used to map child components and add
ports to components.
ParentID is the parent component ID.
The information about ports is passed as values in a MATLAB table against predefined column names, where:
Name is the port name.
Direction can be one of
ID is a user-defined port ID used to map ports to port
CompID is the ID of the component to which the port is added.
It is the component passed in the components table.
The information about connections is passed as values in a MATLAB table against predefined column names, where:
Name is the connection name.
ID is connection ID used to check that the connections are
properly created during the import process.
Kind is the kind of connection specified by
Data by default or
Kind column is optional and will default to
Data if undefined.
SourcePortID is the ID of the source port.
DestPortID is the ID of the destination port.
PortIDs are a comma-separated list of port IDs for physical
ports that support nondirectional connections.
Import the basic architecture from the tables created above into System Composer from the MATLAB Command Window.
The basic architecture model opens.
The tables do not include information about the model's visual layout. You can arrange the components manually or use Architecture > Arrange > Arrange Automatically.
You can import other model elements into the basic structure tables.
To define the data interfaces, add interface names in the
table to associate ports to corresponding
portInterfaces table. Create
a table similar to
connections. Information like interface name, associated element name
along with data type, dimensions, units, complexity, minimum, and maximum values are
passed to the
importModel function in a table format shown
defined with data elements
interface1. Data element
elem2 is typed by
interface2, inheriting its structure. For more information, see Nest Interfaces to Reuse Data.
Owned interfaces cannot be nested. You cannot define an owned interface as the data type of data elements. For more information, see Define Owned Interfaces Local to Ports.
This data interface
interface1 includes a data element
elem3, which is typed by a value type
and inherits its properties. For more information, see Create Value Types as Interfaces.
This physical interface
interface3 includes physical elements
mech, which are typed under their
respective physical domains. For more information, see Specify Physical Interfaces on the Ports.
To map the added data interface to ports, add the column
InterfaceID in the
ports table and specify the
data interface to be linked. For example,
interface1 is mapped to
Port1 as shown below.
You can add variant components just like any other component in the
components table, except you specify the name of the active variant.
Add choices as child components to the variant components. Specify the variant choices as
string values in the
VariantControl column. You can enter expressions
VariantCondition column. For more information, see Create Variants.
Add a variant component
VarComp using component type
Variant with choices
Choice2 as the active choice.
To add a referenced Simulink® model, change the component type to
Behavior and specify
the reference model name
To add a Stateflow® chart behavior on a component, change the component type to
StateflowBehavior. If System Composer does not detect a license or installation of Stateflow, a
Composition component is imported instead.
Pass the modified
components table along with the
connections tables to the
To apply stereotypes on components, ports, and connections, add a
StereotypeNames column to the
components table. To
set the properties for the stereotypes, add a column with a name defined using the profile
name, stereotype name, and property name. For example, name the column
UAVComponent_OnboardElement_Mass for a
UAVComponent profile, a
You set the property values in the format
and values are populated from the default values defined in the loaded profile file. For
more information, see Define Profiles and Stereotypes.
To assign requirement links to the model, add a
table with these required columns:
Label is the name of the requirement.
ID is the ID of the requirement.
SourceID is the architecture element to which the requirement
DestinationType is how requirements are saved.
DestinationID is where the requirement is located.
Type is the requirement type.
For more information, see Manage Requirements.
A Simulink Requirements™ license is required to import requirement links into a System Composer architecture model.
connections table, you can specify different kinds of signal
interface elements as source elements or destination elements. Connections can be formed
from a root architecture port to a component port, from a component port to a root
architecture port, or between two root architecture ports of the same architecture.
The nested interface element
mobile.elem is the source element for
the connection between an architecture port and a component port. The nested element
mobile.alt is the destination element for the connection between an
architecture port and a component port. The interface element
and the nested element
mobile.alt are source elements for the
connection between two architecture ports of the same architecture.
For more information, see Specify a Source Element or Destination Element for Ports on a Connection.
To specify that the architecture to be imported is a software architecture, specify
the domain field of the import structure as
"Software". For more
information, see Import and Export Software Architectures.
To export a model, pass the model name as an argument to the
exportModel function. The function returns a structure containing
requirementLinks, and the field
domain that is a
character vector that represents the type of architecture being exported. The value of
'System' for architecture models or
'Software' for software architecture models.
exportedSet = systemcomposer.exportModel(modelName)
You can export the set to MATLAB tables and then convert those tables to external file formats, including Microsoft® Excel® or databases.
If requirements were imported to the model using an external file, in order to export
and reimport those requirements, update reference requirement links within the model. You
can use this API for the requirement links to point to the imported referenced requirements
instead of the external documents. You can use the
systemcomposer.updateLinksToReferenceRequirements function to make the
requirement links point to the imported referenced requirements instead of the external