Main Content

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 of your model.

  1. Return to the top level of the sldemo_fuelsys model.

  2. On the Apps tab, open the Metrics Dashboard by clicking Metrics Dashboard.

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

Analyze Metric Data

The Metrics Dashboard contains widgets that visualize 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 (which appears green in the widget) or produces a warning (which appears yellow in the widget). Metrics that do not have threshold values appear blue. Functions and classes are available for specifying noncompliant ranges and for changing the threshold values.

Metrics Dashboard showing compliance data and information for the sldemo_fuelsys model

In the Architecture section of the dashboard, locate the Model Complexity widget. To view tooltips, pause over each vertical bar. 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. Components with cyclomatic complexity above 30 return warnings. For more information, see Cyclomatic Complexity Metric.

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 analyze the model complexity details at the model, subsystem, and chart level, click a bar 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.

Table showing details about the cyclomatic complexity metric for the sldemo_fuelsys model and its subsystems, charts, and MATLAB Function blocks

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

Stateflow chart for the control logic

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 example, you could refactor the control_logic chart by moving the logic into atomic subcharts to reduce the complexity for that component.

Next, you will use the Modeling Guideline Compliance widgets to fix issues associated with high-integrity Model Advisor checks.