This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Collect Model Metric Data by Using the Metrics Dashboard

To collect model metric data and assess the design status and quality of your model, use the Metrics Dashboard. The Metrics Dashboard provides a view into the size, architecture, and guideline compliance for your model.

  1. Open the model by typing sldemo_fuelsys.

  2. In the model window, open the Metrics Dashboard by selecting Analysis > Metrics Dashboard.

  3. To collect metric data for this model, click the All Metrics icon.

Analyze Metric Data

The Metrics Dashboard contains widgets that provide visualization of metric data in these categories: size, modeling guideline compliance, and architecture. By default, some widgets contain metric threshold values. These values specify whether your metric data is compliant (appears green in the widget) or produces a warning (appears yellow in the widget). Metrics that do not have threshold values appear blue in the widget. You can specify noncompliant ranges and apply other Metrics Dashboard customizations. For more information, see Customize Metrics Dashboard Layout and Functionality.

In the ARCHITECTURE section of the dashboard, locate the Model Complexity widget. This widget is a visual representation of the distribution of complexity across the components in the model hierarchy. For each complexity range, a colored bar indicates the number of components that fall within that range. Darker green colors indicate more components. In this case, several components have a cyclomatic complexity value in the lowest range, while just one component has a higher complexity. This component has a cyclomatic complexity above 30, which is the default threshold between compliant and warning.

Drill-In to Explore Metric Data

To explore metric data in more detail, click an individual metric widget. For your selected metric, a table displays the value, aggregated value, and measures (if applicable) at the model component level. From the table, the dashboard provides traceability and hyperlinks to the data source so that you can get detailed results.

To drill into model complexity details at the model, subsystem, and chart level, click anywhere in the Model Complexity widget. In this example, the control_logic chart has a cyclomatic complexity value of 51, which is yellow because it is in the warning range.

To see this component in the model, click the control_logic hyperlink.

Refactor Model Based on Metric Data

Once you have used the dashboard to determine which components you must modify to meet quality standards, you can refactor your model. For the Modeling Guideline Compliance widgets, to fix issues, open the Model Advisor. For the Potential Reuse widget, to create and link to library blocks, open the Clone Detection tool. Open the Model Advisor and the Clone Detection tool by clicking respective buttons on the drill-in details.

For this example, refactoring the control_logic chart by moving logic into atomic subcharts reduces the complexity for that component.

Related Topics