Model Metrics
Model Metrics
Model metrics analyze your model and help you assess your model with regard to size, architecture, readability, and compliance to standards. Simulink® Check™ provides the metrics for these metric types:
Using the Metrics Dashboard, you can collect and view model metrics to get an assessment of your project quality status. For more information, see Collect and Explore Metric Data by Using Metrics Dashboard.
You can use the model metric API to run the model metrics programmatically and export the results to a file. For more information, see Collect Model Metrics Programmatically.
For your company guidelines and standards, you can also use the model metric API to create your own model metrics, compute those metrics, and export the metric data. For more information, see Create a Custom Model Metric for Nonvirtual Block Count. You can also create custom metrics for Model Advisor checks. For more information, see Change Model Advisor Checks in Metrics Dashboard.
To obtain the metric IDs for the available metrics in your metric engine, use slmetric.metric.getAvailableMetrics
.
availableMetricIDs = slmetric.metric.getAvailableMetrics()
slmetric.metric.getAvailableMetrics()
returns the available metrics
in your metrics engine, including custom metrics. For information on how to configure and
use custom metrics to customize the dashboard, see Customize Metrics Dashboard Layout and Functionality.
Size Metrics
To collect metric data on a model or subsystem, run these metrics.
Metric | Description |
---|---|
Simulink Block Metric | Calculates the number of blocks in the model. |
Subsystem Metric | Calculates the number of subsystems in the model. |
Library Link Metric | Calculates the number of library-linked blocks in the model. |
Effective Lines of MATLAB Code Metric | Calculates the number of effective lines of MATLAB® code. |
Stateflow Chart Objects Metric | Calculates the number of Stateflow® objects. |
Lines of Code for Stateflow Blocks Metric | Calculates the lines of code for the following Stateflow blocks in the model:
|
Subsystem Depth Metric | Calculates the subsystem depth of the model. |
Input Output Metric | Calculates the number of inputs and outputs in your model. |
Explicit Input Output Metric | Calculates the number of inputs and outputs in your model. |
File Metric | Calculates the number of model and library files. |
MATLAB Function Metric | Calculates the number of MATLAB Function blocks in your model. |
Model File Count | Calculates the number of model files. |
Parameter Metric | Calculates the number of instances of data objects that parameterize the behavior of a model. |
Stateflow Chart Metric | Calculates the number of Stateflow charts in your model. |
For more information on model metrics, see Collect Model and Testing Metrics.
Architecture Metrics
To learn more about the architecture for a model or subsystem, run these metrics.
Metric | Description |
---|---|
Cyclomatic Complexity Metric | Calculates the cyclomatic complexity of the model. |
Clone Content Metric | Calculates the fraction of total number of subcomponents that are clones. |
Clone Detection Metric | Calculates the number of clones in components across the model hierarchy. |
Library Content Metric | Calculates the fraction of total number of components that are linked library blocks. |
For more information on model metrics, see Collect Model and Testing Metrics.
Compliance Metrics
To determine if your model or subsystem is compliant with standards and guidelines, run one or more of these metrics.
Metric | Description |
---|---|
MATLAB Code Analyzer Warnings | Determines warnings for MATLAB code blocks in your model. |
Diagnostic Warnings Metric | Calculates the number of diagnostic warnings reported. |
Model Advisor Check Compliance for High-Integrity Systems | Returns the fraction of checks the model passes from Model Advisor DO-178C/DO-331 Standards. |
Model Advisor Check Compliance for Modeling Standards for MAB | Returns the fraction of checks the model passes from Model Advisor MAB Standard. |
Model Advisor Check Issues for High-Integrity Systems | Reports the number of issues from Model Advisor DO-178C/DO-331 Standards. |
Model Advisor Check Issues for MAB Standards | Reports the number of issues from Model Advisor MAAB Standard. |
For information on compliance metrics that obtain compliance and issues metric data on your Model Advisor configuration, see Compliance Metrics for Model Advisor Configurations.
For more information on model metrics, see Collect Model and Testing Metrics.
Readability Metrics
Run these metrics to determine readability for a model or subsystem.
Metric | Description |
---|---|
Nondescriptive Block Name Metric | Determines nondescriptive Inport, Outport, and Subsystem block names. |
Data and Structure Layer Separation Metric | Calculates the data and structure layer separation. |
For more information on model metrics, see Collect Model and Testing Metrics.
Compliance Metrics for Model Advisor Configurations
The Metrics Dashboard and metric APIs can obtain compliance and issues metric data for your Model Advisor configuration or for an existing check group, such as the MISRA checks. To set up your own Model Advisor configuration, see Use Model Advisor Configuration Editor to Customize Model Advisor.
You can configure Model Advisor compliance metrics and Model Advisor compliance issues metrics by creating metric IDs for custom Model Advisor metrics. For more information, see Change Model Advisor Checks in Metrics Dashboard.
Model Advisor Compliance Metrics
Metric Type: Compliance
Family ID:
mathworks.metrics.ModelAdvisorCheckCompliance
Metric ID: <Family ID>.<Model Advisor Check Group ID>
Use this metric to calculate the fraction of Model Advisor checks that pass for the selected group of checks.
For Model Advisor compliance metrics, the Family ID
is mathworks.metrics.ModelAdvisorCheckCompliance
.
To obtain the Model Advisor Check Group ID, open the Model Advisor Configuration Editor and select the folder that contains the desired group of checks. The Check Group ID is shown in the Information tab. For information on the Model Advisor Configuration Editor, see Use Model Advisor Configuration Editor to Customize Model Advisor.
For an example of how to use Model Advisor compliance metrics, see Change Model Advisor Checks in Metrics Dashboard.
Model Advisor Compliance Issues Metrics
Metric Type: Compliance
Family ID:
mathworks.metrics.ModelAdvisorCheckIssues
Metric ID: <Family ID>.<Model Advisor Check Group ID>
Use this metric to calculate the number of issues reported by the selected group of Model Advisor checks. This metric counts each Model Advisor check, in the selected group of Model Advisor checks, that produces a warning or failure.
For Model Advisor compliance issues metrics, the Family
ID is mathworks.metrics.ModelAdvisorCheckIssues
.
To obtain the Model Advisor Check Group ID, open the Model Advisor Configuration Editor and select the folder that contains the desired group of checks. The Check Group ID is shown in the Information tab. For information on the Model Advisor Configuration Editor, see Use Model Advisor Configuration Editor to Customize Model Advisor.
For an example of how to use Model Advisor compliance metrics, see Change Model Advisor Checks in Metrics Dashboard.