Main Content

Import and Export Architecture Models

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.

Define a Basic Architecture

The minimum required structure for a System Composer model consists of these sets of information:

  • Components table

  • Ports table

  • Connections table

To import additional elements, you need to add columns to the tables and add specific values for these elements.

Components Table

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.

For example, Component_1_1 and Component_1_2 are children of Component_1.


Ports Table

The information about ports is passed as values in a MATLAB table against predefined column names, where:

  • Name is the port name.

  • Direction is an input or output port direction.

  • ID is a user-defined port ID used to map ports to port connections.

  • CompID is the ID of the component to which the port is added. It is the component passed in the components table.


Connections 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.

  • SourcePortID is the ID of the source port.

  • DestPortID is the ID of the destination port.


Import a Basic Architecture

Import the basic architecture from the tables created above into System Composer from the MATLAB Command Window.


The basic architecture model opens.

Basic architecture model.


The tables do not include information about the model's visual layout. You can arrange the components manually or use Architecture > Arrange > Arrange Automatically.

Extend the Basic Architecture Import

You can import other model elements into the basic structure tables.

Import Interfaces and Map Ports to Interfaces

To define the interfaces, add interface names in the ports table to associate ports to corresponding portInterfaces table. Create a table similar to components, ports, and 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 below.

interface23 11""real"[]""[]"


Anonymous interfaces cannot be nested. You cannot define an anonymous interface as the data type of elements.

To map the added interface to ports, add column InterfaceID in the ports table to specify the interface to be linked. For example, interface1 is mapped to Port1 as shown below.


Import Variant Components, Stateflow Behaviors, or Reference Components

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 in the VariantCondition column.

Add a variant component VarComp using component type Variant with choices Choice1 and Choice2. Set Choice2 as the active choice.

To add a referenced Simulink® model, change the component type to Behavior and specify the reference model name simulink_model.

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.

VarCompV20 VariantChoice2  
Choice1C6V2   petrol 
Choice2C7V2   diesel 
Component3C30 StateflowBehavior   

Pass the modified components table along with the ports and connections tables to the importModel function.

Apply Stereotypes and Set Property Values on Imported Model

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 OnBoardElement stereotype, and a Mass property.

You set the property values in the format value{units}. Units and values are populated from the default values defined in the loaded profile file.


Assign Requirement Links on Imported Model

To assign requirement links to the model, add a requirementLinks 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 is attached.

  • DestinationType is how requirements are saved.

  • DestinationID is where the requirement is located.

  • Type is the requirement type.

rset#11components:1 linktype_rmi_slreqC:\Temp\rset.slreqx#1Implement
rset#22components:0 linktype_rmi_slreqC:\Temp\rset.slreqx#2Implement

A Simulink Requirements™ license is required to import requirement links into a System Composer architecture model.

Specify Elements on Architecture Port

In the 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.

Interface design with nested interface.

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 mobile and the nested element mobile.alt are source elements for the connection between two architecture ports of the same architecture.

Comp1ToRoot326 interface
Comp2ToRoot436 mobile.alt

Export an Architecture

To export a model, pass the model name and as an argument to the exportModel function. The function returns a structure containing four tables components, ports, connections, portInterfaces, and requirementLinks.

>> 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.

Five tables in a structure called components, ports, connections, port interfaces, and requirement links.

Update Reference Requirement Links from Imported File

After importing requirement links from a file, update links to reference requirements for the model to make full use of the Simulink® Requirements™ functionality.

model = systemcomposer.openModel('reqImportExample');

Import Requirement Links from Word File

Open the Microsoft® Word file Functional_Requirements.docx with the requirements listed. Highlight the requirement to link.

In the model, select the component to which to link the requirement. From the drop-down list, select Requirements > Link Selection to Word.

Export Model and Save to External Files

Export the model and save to an external file.

exportedSet = systemcomposer.exportModel('reqImportExample');

Import Requirement Links from File and Import to Model

Use the external files to import requirement links into another model.

structModel = ImportModelFromExcel('exportedModel.xls','Components','Ports', ...

arch = systemcomposer.importModel('reqNewExample',structModel.Components, ...

Update Links to Reference Requirements

To integrate the requirement links to the model, update references within the model.

model2 = systemcomposer.openModel('reqNewExample');

See Also

| | |

Related Topics