Main Content

Analyze an Architecture Model

A profile contains a set of model element stereotypes with custom properties. A stereotype can be applicable to components, ports, connections, interfaces, and architectures, or it can made applicable only to a specific element type, such as components. When a model element has a stereotype applied to it, you can specify property values as part of its architectural definition. In addition to allowing you to manage properties relevant to the system specification within the architecture model, stereotypes and associated properties also facilitate analysis of an architecture model.

Profile structure with name 'System Standard' and three stereotypes named 'System Element', 'Software Component', and 'Physical Connector' all with some properties.

Each profile contains a set of stereotypes, and each stereotype contains a set of properties.

The goal of this example is to compute the total cost of the system given the cost of its constituent parts. The example profile is limited to this goal.

Load Architecture Model Profile

Load a profile to make stereotypes available for model elements.

  1. Start System Composer. Enter systemcomposer at the MATLAB command line.

  2. In the Modeling tab, select Import and then from the drop-down, select Import .

  3. Browse to the examples folder. <matlabroot>\toolbox\systemcomposer\examples.

  4. Select simpleProfile.

  5. From the toolstrip, click Import and select Edit to open the Profile Editor.

    The System Composer Profile Editor with stereotype 'Sys General' with properties defined 'ID' and "Note'.

In the profile, observe these stereotypes.

sysGeneralcomponents, ports, connectors

ID (integer, no units)

Note (string, no units)


weight (double, kg)

unitPrice (double, USD)


length (double, m)

weight (double, kg/m)

unitPrice (double, USD/m)

Importing the profile makes stereotypes available to their applicable elements.

  • sysGeneral is a general stereotype, applicable to all element types, that enables adding generic properties such as a Note, which project members can use to track any issues with the element.

  • sysComponent applies only to components, and includes properties such as weight and cost that contribute to the total weight and cost specifications of the robot system.

  • sysConnector stereotype applies to connectors, and includes price and weight properties defined per meter of length (assuming a physical connector like a wire). These properties help compute the total weight and cost of the design in this particular example.

  • sysPort stereotype applies to ports and does not include any properties.


You can add a stereotype icon to all component-level stereotypes. These are your choices:

Stereotype icons available.

Apply Stereotypes to Model Elements

Add custom properties to a model element by applying a stereotype from a loaded profile. This procedure uses the model ex_RobotArch.


  1. In the Modeling tab, select Import and then from the drop-down, select Import .

  2. Select simpleProfile.

  3. Open the Sensors component.

  4. On the Modeling tab, select Apply Stereotypes.

  5. In the Apply Stereotypes dialog box and from the Apply stereotype(s) to list, select All elements. From the Scope list, select This layer.

    In the list of available stereotypes, select simpleProfile.sysGeneral.

    Apply Stereotypes dialog with stereotype name displayed.

  6. Click Apply and close the window to exit the dialog box.

  7. Select the GPS component. Right-click and select Apply Stereotype. Select the simpleProfile.sysComponent stereotype.


    The sysComponent stereotype is used for managing physical properties and cost.

    Repeat for the GyroData and DataProcessing components.

  8. Navigate to top of the model. Apply the sysComponent stereotype to the Sensors and Trajectory Planning components, and the top-level architecture model. Right-click each component or a space in the top-level, and select Apply Stereotype to ensure simpleProfile.sysComponent is selected.

  9. Apply the sysConnector stereotype is applied to all connectors in the Sensors layer, the Trajectory Planning layer, and the top model layer. Press and hold Shift to select multiple connectors. Right-click the selection, click Apply Stereotype, and select the sysConnector stereotype.

    Inspect that the connectors have two stereotypes selected using the right click menu and selecting 'Apply Stereotype'.

Set Properties

Set the property values to enable cost analysis. Follow this example for the GPS module.

  1. In the Sensors component, select the GPS component.

  2. Open the Property Inspector. Click the drop-down in the Design section of the toolstrip and select Property Inspector.

  3. Expand the sysComponent stereotype to see the properties.

  4. Set unitPrice to 5 and press Enter.

  5. Select the GPSData port connector. Check that length is set to 0.05 and unitPrice to 0.1.

    GPS Data port connector is selected.

  6. Complete the model using the values in this table. If a property is not in the table, you can leave it blank as it has no effect on the analysis. Pin the Property Inspector to the editor to make it permanently visible during this operation.

    Top layerEncoder connectorlength0.5
    SensorData connectorlength0.6
    MotionCommand connectorlength0.5
    Sensors componentunitPrice5
    Trajectory Planning componentunitPrice500
    Motion componentunitPrice750
    Sensors layerGyroData componentunitPrice50
    DataProcessing componentunitPrice500
    GPS componentunitPrice100
    GPSData connectorlength0.05
    MotionData connectorlength0.05
    RawData connectorlength0.05
  7. The properties are already set in ex_RobotArch_props.slx. Open the model to perform an analysis.


Perform an Analysis

Analyze the total cost for all components in the robot model.

  1. On the Modeling tab and in the Views section, select Analysis Model, and then from the drop-down list select Analysis Model.

  2. Add an analysis function. In the Analysis function box, enter the function name ex_RobotArch_analysis without an extension, and then click the add analysis button. A MATLAB function file is created and saved with the name ex_RobotArch_analysis.m.

    Instantiate architecture model screen with all stereotypes selected. Configure analysis to use iteration order pre-order.

    The analysis function includes constructs that get properties from model elements, given as a template. Modify this template to add the cost of individual elements to obtain total cost for their parent architecture. This function computes the cost for one model element as a total of its own cost and the cost of all of its child components.

    function ex_RobotArch_analysis(instance,varargin)
    if instance.isComponent()
         if instance.hasValue("sysComponent.unitPrice")
             sysComponent_unitPrice = instance.getValue("sysComponent.unitPrice");
             for child = instance.Components
                 if child.hasValue("sysComponent.unitPrice")
                     comp_price = child.getValue("sysComponent.unitPrice");
                     sysComponent_unitPrice = sysComponent_unitPrice + comp_price;
             for child = instance.Connectors
                 if child.hasValue("sysConnector.unitPrice")
                     unitPrice = child.getValue("sysConnector.unitPrice");
                     length = child.getValue("sysConnector.length");
                     sysComponent_unitPrice = unitPrice*length + sysComponent_unitPrice;
  3. Return to the Instantiate Architecture Model screen and click Instantiate. The Analysis Viewer shows the properties of each model element. The default values for the start of the Analysis are taken from the property values you entered when you attached the stereotype to the model and edited their values.

  4. In the Analysis section, select BottomUp as the iteration method and click Analyze.

    The cost of each element is added in a bottom-up manner to find the cost of the system. The result is written to the analysis instance and is visible in the Analysis Viewer.

    Analysis viewer with data.

See Also

| | | | | | |

Related Topics