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 the 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.
To obtain the metric IDs for the available metrics in your metric engine, use slmetric.metric.getAvailableMetrics
.
availableMetricIDs = slmetric.metric.getAvailableMetrics()
availableMetricIDs = 26×1 cell array {'mathworks.metrics.CloneContent' } {'mathworks.metrics.CloneDetection' } {'mathworks.metrics.CyclomaticComplexity' } {'mathworks.metrics.DescriptiveBlockNames' } {'mathworks.metrics.DiagnosticWarningsCount' } {'mathworks.metrics.ExplicitIOCount' } {'mathworks.metrics.FileCount' } {'mathworks.metrics.IOCount' } {'mathworks.metrics.LayerSeparation' } {'mathworks.metrics.LibraryContent' } {'mathworks.metrics.LibraryLinkCount' } {'mathworks.metrics.MatlabCodeAnalyzerWarnings' } {'mathworks.metrics.MatlabFunctionCount' } {'mathworks.metrics.MatlabLOCCount' } {'mathworks.metrics.ModelAdvisorCheckCompliance.hisl_do178'} {'mathworks.metrics.ModelAdvisorCheckCompliance.maab' } {'mathworks.metrics.ModelAdvisorCheckIssues.hisl_do178' } {'mathworks.metrics.ModelAdvisorCheckIssues.maab' } {'mathworks.metrics.ModelFileCount' } {'mathworks.metrics.ParameterCount' } {'mathworks.metrics.SimulinkBlockCount' } {'mathworks.metrics.StateflowChartCount' } {'mathworks.metrics.StateflowChartObjectCount' } {'mathworks.metrics.StateflowLOCCount' } {'mathworks.metrics.SubSystemCount' } {'mathworks.metrics.SubSystemDepth' }
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 librarylinked 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 HighIntegrity Systems  Returns the fraction of checks the model passes from Model Advisor DO178C/DO331 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 HighIntegrity Systems  Reports the number of issues from Model Advisor DO178C/DO331 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.
Simulink block metric
Metric Type: Size
Metric ID:
mathworks.metrics.SimulinkBlockCount
Model Advisor Check ID:
mathworks.metricchecks.SimulinkBlockCount
Calculate the number of Simulink blocks in the model.
Description
Use this metric to calculate the number of blocks in the model. The results provide the
number of blocks at the model and subsystem level. This metric counts Simulink—based
blocks, but does not include underlying blocks used to implement the block. This metric is
available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.SimulinkBlockCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect data for this metric using the Model Advisor, run the check, Simulink block metric in By Task > Model Metrics > Count Metrics. The Model Advisor check displays the number of blocks in the model or the subsystem. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of blocks.AggregatedValue
: Number of blocks for component and its subcomponents.Measures
: Not applicable.
Note
The results from metric analysis of Simulink block metric can
differ from calling sldiagnostics
. The result of the Simulink
block metric:
Includes referenced models.
Does not include any underlying blocks used to implement a MathWorks block that you used from the Simulink Library Browser.
Does not include links into MathWorks libraries, which means that MathWorks library blocks that are masked subsystems are counted as one block. The inner content of those blocks is not counted.
Does not include hidden content under Stateflow Charts or MATLAB Function blocks.
Does not include requirements blocks.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Subsystem metric
Metric Type: Size
Metric ID:
mathworks.metrics.SubSystemCount
Model Advisor Check ID:
mathworks.metricchecks.SubSystemCount
Display number of subsystems in the model.
Description
Use this metric to calculate the number of subsystems in the model. The results provide the number of subsystems at the model and subsystem level.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.SubSystemCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect data for this metric using the Model Advisor, run the check, Subsystem metric in By Task > Model Metrics > Count Metrics. The Model Advisor check displays the number of subsystems in the model or the subsystem. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of subsystems.AggregatedValue
: Number of subsystems for a component and its subcomponent.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
Does not count subsystems linked to MathWorks^{®} libraries.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Library link metric
Metric Type: Size
Metric ID:
mathworks.metrics.LibraryLinkCount
Model Advisor Check ID:
mathworks.metricchecks.LibraryLinkCount
Display number of library links in the model.
Description
Use this metric to calculate the number of librarylinked blocks in the model. The results provide the number of librarylinked blocks at the model and subsystem level.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.LibraryLinkCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect results for this metric using the Model Advisor, run the check, Library link metric in By Task > Model Metrics > Count Metrics.The Model Advisor check displays the number of library links in the model or the subsystem. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of library linked blocks.AggregatedValue
: Number of library linked blocks for a component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
Does not count subsystems linked to MathWorks libraries.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Effective lines of MATLAB code metric
Metric Type: Size
Metric ID:
mathworks.metrics.MatlabLOCCount
Model Advisor Check ID:
mathworks.metricchecks.MatlabLOCCount
Display number of effective lines of MATLAB code.
Description
Run this metric to calculate the number of effective lines of MATLAB code. Effective lines of MATLAB code are lines of executable code. Empty lines, lines that contain only comments, and lines that contain only an end statement are not considered effective lines of code. The results provide the number of effective lines of MATLAB code for each MATLAB Function block and for MATLAB functions in Stateflow charts.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.MatlabLOCCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect results for this metric using the Model Advisor, run the check, Effective lines of MATLAB code metric in By Task > Model Metrics > Count Metrics. The Model Advisor check displays the number of effective lines of MATLAB code for each MATLAB Function block and for MATLAB functions in Stateflow charts in the model. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of effective lines of MATLAB code.AggregatedValue
: Number of effective lines of MATLAB code for a component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
Does not analyze the content of MATLAB code in external files.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Stateflow chart objects metric
Metric Type: Size
Metric ID:
mathworks.metrics.StateflowChartObjectCount
Model Advisor Check ID:
mathworks.metricchecks.StateflowChartObjectCount
Display the number of Stateflow objects in each chart.
Description
Run this metric to calculate the number of Stateflow objects. For each chart in the model, the results provide the number of the following Stateflow objects:
Atomic subcharts
Boxes
Data objects
Events
Graphical functions
Junctions
Linked charts
MATLAB functions
Notes
Simulink functions
States
Transitions
Truth tables
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.StateflowChartObjectCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect results for this metric using the Model Advisor, run the check, Stateflow chart objects metric in By Task > Model Metrics > Count Metrics. The Model Advisor check displays the number of Stateflow objects in each chart in the model. The check does not analyze charts in referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of Stateflow objects.AggregatedValue
: Number of Stateflow objects for a component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Lines of code for Stateflow blocks metric
Metric Type: Size
Metric ID:
mathworks.metrics.StateflowLOCCount
Model Advisor Check ID:
mathworks.metricchecks.StateflowLOCCount
Display the number of effective lines of code for Stateflow blocks.
Description
Use this metric to calculate the number of effective lines of code in Stateflow. Effective lines of MATLAB code are lines of executable code. Empty lines, lines that contain only comments, and lines that contain only an end statement are not considered effective lines of code. This metric calculates the lines of code for the following Stateflow blocks in the model:
Chart, counting the code on Transitions and inside States
State Transition Table block
Truth Table block
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.StateflowLOCCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect results for this metric using the Model Advisor, run the check, Lines of code for Stateflow blocks metric in By Task > Model Metrics > Count Metrics. The Model Advisor check displays the number of code lines for Stateflow blocks in the model. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of Stateflow block code lines.AggregatedValue
: Number of Stateflow block code lines for a component and its subcomponents.Measures
: Vector with two entries: number of effective lines of code in MATLAB action language and number of effective lines of code in C action language.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Subsystem depth metric
Metric Type: Size
Metric ID:
mathworks.metrics.SubSystemDepth
Model Advisor Check ID:
mathworks.metricchecks.SubSystemDepth
Calculates the depth of the hierarchical children of a subsystem or model.
Description
Use this metric to count the relative depth of all hierarchical children for a given subsystem or model starting from the given component, or root of analysis. Depth traversal analysis stops when it reaches a referenced model or a library. Depth is restarted with 0 for each of these components.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.SubSystemDepth
.
The slmetric.metric.AggregationMode
property setting is
None
.
Model Advisor Check
To collect results for this metric using the Model Advisor, run the check, Subsystem depth metric in By Task > Model Metrics > Count Metrics. The Model Advisor check displays the depth of the subsystems in the model. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: subsystem depth for each component in the hierarchy.AggregatedValue
: Not applicable.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Input output metric
Metric Type: Size
Metric ID:
mathworks.metrics.IOCount
Display number of inputs and outputs in the model.
Description
Use this metric to calculate the number of inputs and outputs in the model, which include:
Inputs: Inport blocks, Trigger ports, Enable ports, chart input data and events.
Outputs: Outport blocks, chart output data and events.
Implicit inputs: From block, where the matching Goto block is outside of the component.
Implicit outputs: Goto block, where the matching From block is outside of the component.
The slmetric.metric.AggregationMode
property setting is
Max
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: total interface size or sum of the elements ofMeasures
.AggregatedValue
: Number of inputs and outputs for a component and its subcomponents.Measures
: Array consisting of number of inputs, number of outputs, number of implicit inputs, and number of implicit outputs, which are local to the component.AggregatedMeasures
: Maximum number of inputs, outputs, implicit inputs, and implicit outputs for a component and subcomponents.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Diagnostic warnings metric
Metric Type: Compliance
Metric ID:
mathworks.metrics.DiagnosticWarningsCount
Calculate the number of diagnostic warnings reported during a model update for simulation.
Description
Use this metric to calculate the number of Simulink diagnostic warnings reported during a model update for simulation. This metric
is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.DiagnosticWarningsCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of diagnostic warnings reported.AggregatedValue
: Number of diagnostic warnings reported for component and its subcomponents.Measure
: Not applicable.
Capabilities and Limitations
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Explicit input output metric
Metric Type: Size
Metric ID:
mathworks.metrics.ExplicitIOCount
Display number of inputs and outputs in the model, excluding From and Goto blocks.
Description
Use this metric to calculate the number of inputs and outputs in the model, which include:
Inputs: Inport blocks, Trigger ports, Enable ports, chart input data and events.
Outputs: Outport blocks, chart output data and events.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.ExplicitIOCount
.
The slmetric.metric.AggregationMode
property setting is
Max
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Total interface size or sum of the elements ofMeasures
.AggregatedValue
: Number of inputs and outputs for a component and its subcomponents.Measures
: Array consisting of number of inputs and number of outputs which are local to the component.AggregatedMeasures
: Maximum number of inputs and outputs for a component and subcomponents.
Capabilities and Limitations
The metric:
Excludes From and Goto blocks.
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
File metric
Metric Type: Size
Metric ID:
mathworks.metrics.FileCount
Calculates the number of model and library files used by a specific component and its subcomponents.
Description
Use this metric to count the number of model and library files used by a specific
component and its subcomponents. This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.FileCount
.
The slmetric.metric.AggregationMode
property setting is
None
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of model and library files.AggregatedValue
: Not applicable.Measures
: Not applicable.
Capabilities and Limitations
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
MATLAB Function metric
Metric Type: Size
Metric ID:
mathworks.metrics.MatlabFunctionCount
Calculates the number of MATLAB Function blocks inside a component.
Description
Use this metric to count the number of MATLAB Function blocks inside a
component. This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.MatlabFunctionCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of MATLAB Function blocks.AggregatedValue
: Number of MATLAB Function blocks for component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Model file count
Metric Type: Size
Metric ID:
mathworks.metrics.ModelFileCount
Calculate the number of model files.
Description
Use this metric to count the number of model files. This metric is available with
Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.ModelFileCount
.
The slmetric.metric.AggregationMode
property setting is
None
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of files reference by a component and its subcomponents.AggregatedValue
: Not applicable.Measures
: Not applicable.
Capabilities and Limitations
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Parameter metric
Metric Type: Size
Metric ID:
mathworks.metrics.ParameterCount
Calculate number of instances of parameter data
Description
Use this metric to calculate the number of instances of parameter data inside a Simulink system.
A parameter is a variable used by a Simulink block or object of a basic type (which includes single
,
double
, uint8
, uint16
,
uint32
, int8
, int16
,
int32
, boolean
, logical
,
struct
, char
, cell
),
Simulink.Parameter
object, Simulink.Variant
object,
or enum
value. This metric returns every instance of a parameter in a
model, which means that the metric counts each instance of a parameter separately. The
parameter data must be located in the base workspace, the model workspace, or a data
dictionary.
For example, the model f14
uses two instances of the parameter
Zw
. One instance is in block f14/Gain
at the root
level of the model. One instance is in block f14/Aircraft Dynamics Model/Transfer
Fcn.2
in the Aircraft Dynamics Model
subsystem. The metric
mathworks.metrics.ParameterCount
includes both of these instances of
parameter Zw
when it calculates the number of parameter instances in the
f14
model and its subsystems.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.ParameterCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of parameter instances used inside a component.AggregatedValue
: Number of parameter instances for a component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
This metric:
Filters results from the
Simulink.findVars
function and inherits the limitations of this function.Counts the parameter instances in a component rather than unique parameters.
Does not include parameters in masked workspaces.
Does not include data type and signal objects.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Stateflow chart metric
Metric Type: Size
Metric ID:
mathworks.metrics.StateflowChartCount
Calculate the number of Stateflow charts at any component level.
Description
Use this metric to count the number of Stateflow charts at any component level. This metric
is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.StateflowChartCount
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of Stateflow charts at the model level.AggregatedValue
: Number of charts for component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Cyclomatic complexity metric
Metric Type: Architecture
Metric ID:
mathworks.metrics.CyclomaticComplexity
Model Advisor Check ID:
mathworks.metricchecks.CyclomaticComplexity
Display the cyclomatic complexity of the model.
Description
Use this metric to calculate the cyclomatic complexity of the model. Cyclomatic complexity is a measure of the structural complexity of a model. The complexity measure can be different for the generated code than for the model due to code features that this analysis does not consider, such as consolidated logic and error checks. To compute the cyclomatic complexity of an object (such as a block, chart, or state), Simulink Check uses this formula:
N is the number of decision points that the object represents and o_{n} is the number of outcomes for the nth decision point. The calculation considers a vectorized operation or a Multiport switch block as a single decision point. The tool adds 1 to the complexity number for models, atomic subsystems, and Stateflow charts.
The results provide the local and aggregated cyclomatic complexity for the:
Model
Subsystems
Charts
MATLAB functions
Local complexity is the cyclomatic complexity for objects at their hierarchical level. Aggregated cyclomatic complexity is the cyclomatic complexity of an object and its descendants
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.CyclomaticComplexity
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect data for this metric using the Model Advisor, run the check, Cyclomatic complexity metric in By Task > Model Metrics > Complexity Metrics. The Model Advisor check displays the local cyclomatic complexity for the root model and for Simulink and Stateflow objects in the system. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Local cyclomatic complexity.AggregatedValue
: Aggregated cyclomatic complexity.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Does not run on library models.
Analyzes content in masked subsystems.
Does not analyze inactive variants.
If specified, analyzes the content of librarylinked blocks or referenced models.
Does not analyze referenced models in accelerated mode.
See Also
Cyclomatic Complexity for Stateflow Charts (Simulink Coverage)
Specify Coverage Options (Simulink Coverage)
Clone content metric
Metric Type: Architecture
Metric ID:
mathworks.metrics.CloneContent
Calculates the fraction of total number of subcomponents that are clones.
Description
Use this metric to calculate the fraction of the total number of subcomponents that are clones. Clones must have identical block types and connections but they can have different parameter values. For more information on clone detection, see Enable Component Reuse by Using Clone Detection.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.CloneContent
.
The slmetric.metric.AggregationMode
property setting is
None
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Fraction of total number of subcomponents that are clonesAggregatedValue
: Not applicable.Measures
: Vector containing number of clones, total number of components, and clone group number.
Capabilities and Limitations
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Clone detection metric
Metric Type: Architecture
Metric ID:
mathworks.metrics.CloneDetection
Calculate the number of clones in a model.
Description
Use this metric to count the number of clones in a model. Clones must have identical
block types and connections but they can have different parameter values. This metric is
available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.CloneDetection
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of clones.AggregatedValue
: Number of clones for component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Library content metric
Metric Type: Architecture
Metric ID:
mathworks.metrics.LibraryContent
Calculates the fraction of total number of components that are linked library blocks.
Description
Use this metric to calculate the fraction of total number of components that are linked
library blocks. This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.LibraryContent
.
The slmetric.metric.AggregationMode
property setting is
None
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Fraction of the total number of subcomponents that are linked library blocks.AggregatedValue
: Not applicable.Measures
: Vector containing the number of linked library blocks and total number of components
Capabilities and Limitations
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics.
Nondescriptive block name metric
Metric Type: Readability
Metric ID:
mathworks.metrics.DescriptiveBlockNames
Model Advisor Check ID:
mathworks.metricchecks.DescriptiveBlockNames
Display nondescriptive Inport, Outport, and Subsystem block names.
Description
Run this metric to determine nondescriptive Inport, Outport, and Subsystem block names. Default names appended with an integer are nondescriptive block names. The results provide the nondescriptive block names at the model and subsystem levels.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.DescriptiveBlockNames
.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect results for this metric using the Model Advisor, run the check, Nondescriptive block name metric in By Task > Model Metrics > Readability Metrics. The Model Advisor check displays the number of nondescriptive Inport, Outport, and Subsystem block names in the model or subsystem. The check does not display the result for each type of block separately. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of nondescriptive Inport, Outport, and Subsystem block names.AggregatedValue
: Number of nondescriptive Inport, Outport, and Subsystem block names for a component and its subcomponents.Measures
: 1D vector containing:Total number of Inport blocks
Number of Inport blocks with nondescriptive names
Total number of Outport blocks
Number of Outport blocks with nondescriptive names
Total number of Subsystem blocks
Number of Subsystem blocks with nondescriptive names
AggregatedMeasures
: 1D vector containing sum of:Total number of Inport blocks
Number of Inport blocks with nondescriptive names
Total number of Outport blocks
Number of Outport blocks with nondescriptive names
Total number of Subsystem blocks
Number of Subsystem blocks with nondescriptive names
Capabilities and Limitations
The metric:
Does not run on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics
Data and structure layer separation metric
Metric Type: Readability
Metric ID:
mathworks.metrics.LayerSeparation
Model Advisor Check ID:
mathworks.metricchecks.LayerSeparation
Display data and structure layer separation.
Description
Run this metric to calculate the data and structure layer separation. The results provide the separation at the model and subsystem level.
This metric is available with Simulink
Check. To collect data for this metric, use getMetrics
with the metric identifier,
mathworks.metrics.LayerSeparation
.
For guidelines about blocks on model levels, see the MAB guideline db_0143: Usable block types in model hierarchy.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Model Advisor Check
To collect results for this metric using the Model Advisor, run the check, Data and structure layer separation metric in By Task > Model Metrics > Readability Metrics. The Model Advisor check displays the separation for the model or subsystem. The check does not analyze referenced models or return aggregated results.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of basic blocks on a structural level.AggregatedValue
: Number of basic blocks on a structural level for a component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Does not run on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
See Also
For more information on model metrics, see Collect Model and Testing Metrics
MATLAB code analyzer warnings
Metric Type: Compliance
Metric ID:
mathworks.metrics.MatlabCodeAnalyzerWarnings
Use this metric to calculate the number of MATLAB code analyzer warnings from MATLAB code in the model. This metric is available with Simulink Check.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of MATLAB code analyzer warningsAggregatedValue
: Number of MATLAB code analyzer warnings aggregated for a component and subcomponents.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Analyzes MATLAB code in MATLAB Function blocks
Analyzes MATLAB functions in Stateflow charts
Runs on library models
Analyzes content in masked subsystems
If specified, analyzes content of librarylinked blocks and referenced models
Does not analyze external MATLAB code files
See Also
Model Advisor Check Compliance for HighIntegrity Systems
Metric Type: Compliance
Family ID:
mathworks.metrics.ModelAdvisorCheckCompliance
Metric ID:
mathworks.metrics.ModelAdvisorCheckCompliance.hisl_do178
Use this metric to calculate the fraction of Model Advisor checks that pass for the HighIntegrity Systems subgroups. This metric is available with Simulink Check.
The slmetric.metric.AggregationMode
property setting is
Percentile
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Fraction of total number of checks passed in HighIntegrity Systems subgroups.AggregatedValue
: Fraction of total number of checks passed in HighIntegrity Systems subgroups aggregated for a component and all of its subcomponents.Measures
: Vector containing: number of checks passed in subgroups and number of checks in subgroups.AggregatedMeasures
: Vector containing: number of checks passed in subgroups and number of checks in subgroup, for a component and all its subcomponents.
Results Details
For this metric, instances of the slmetric.metric.ResultDetail
Value
property provides these results:
A value of 0 indicates that a check did not run.
A value of 1 indicates that a check passed.
A value of 2 indicates a check warning.
A value of 3 indicates a failure.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
Analyzes content in Stateflow objects.
See Also
Model Advisor Check Compliance for Modeling Standards for MAB
Metric Type: Compliance
Family ID:
mathworks.metrics.ModelAdvisorCheckCompliance
Metric ID:
mathworks.metrics.ModelAdvisorCheckCompliance.maab
Use this metric to calculate the fraction of Model Advisor checks that pass for the group Modeling Standards for MAB. This metric is available with Simulink Check.
The slmetric.metric.AggregationMode
property setting is
Percentile
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Fraction of total number of checks passed in MAB.AggregatedValue
: Fraction of total number of checks passed in MAB aggregated for a component and all of its subcomponents.Measures
: Vector containing: number of checks passed in group and number of checks in group.AggregatedMeasures
: Vector containing: number of checks passed in group and number of checks in group, for a component and all its subcomponents.
Results Details
For this metric, instances of the slmetric.metric.ResultDetail
Value
property provides these results:
A value of 0 indicates that a check did not run.
A value of 1 indicates that a check passed.
A value of 2 indicates a check warning.
A value of 3 indicates a failure.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
Analyzes content in Stateflow objects.
See Also
Model Advisor Check Issues for HighIntegrity Systems
Metric Type: Compliance
Family ID:
mathworks.metrics.ModelAdvisorCheckIssues
Metric ID:
mathworks.metrics.ModelAdvisorCheckIssues.hisl_do178
Use this metric to calculate number of issues reported by the subgroups of Model Advisor checks for HighIntegrity Systems. This metric counts each Model Advisor check that produces a warning or failure. If a check contains links to blocks, this metric counts one issue for each linked block. Checks with links to the model are highlighted in the Simulink Editor. If a check does not contain links to blocks, this metric counts one issue. This metric is available with Simulink Check.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of issues reported by the HighIntegrity Systems checksAggregatedValue
: Number of issues reported by the HighIntegrity Systems checks aggregated for a component and all of its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
Analyzes content in Stateflow objects.
See Also
Model Advisor Check Issues for MAB Standards
Metric Type: Compliance
Family ID:
mathworks.metrics.ModelAdvisorCheckIssues
Metric ID:
mathworks.metrics.ModelAdvisorCheckIssues.maab
Use this metric to calculate number of issues reported by the group of Model Advisor checks for Modeling Standards for MAB. This metric counts each Model Advisor check that produces a warning or failure. If a check contains links to blocks, this metric counts one issue for each linked block. Checks with links to the model are highlighted in the Simulink Editor. If a check does not contain links to blocks, this metric counts one issue. This metric is available with Simulink Check.
The slmetric.metric.AggregationMode
property setting is
Sum
.
Results
For this metric, instances of slmetric.metric.Result
provide the following results:
Value
: Number of issues reported by the Model Advisor for MAB checks.AggregatedValue
: Number of issues reported by the Model Advisor for MAB checks aggregated for a component and its subcomponents.Measures
: Not applicable.
Capabilities and Limitations
The metric:
Runs on library models.
Analyzes content in masked subsystems.
If specified, analyzes the content of librarylinked blocks or referenced models.
Analyzes content in Stateflow objects.
Adds check issues on the configuration set or issues with data objects to the issue count at the model root level.
See Also
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 the Model Advisor Configuration Editor to Customize the Model Advisor.
You can configure Model Advisor compliance metrics and Model Advisor compliance issues metrics.
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 the Model Advisor Configuration Editor to Customize the Model Advisor.
For an example of how to use Model Advisor compliance metrics, see Customize Metrics Dashboard Layout and Functionality.
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 the Model Advisor Configuration Editor to Customize the Model Advisor.
For an example of how to use Model Advisor compliance metrics, see Customize Metrics Dashboard Layout and Functionality.