MATLAB Design Details
R2026bMetric ID
modeldesign.MATLABMaintainability[slcomp.MATLABDesignDetails]
Description
This metric returns detailed maintainability measurements for each MATLAB® design layer in a unit. The measurements include executable lines of code, decision count, Halstead difficulty, and the operator and operand counts used to compute Halstead difficulty. Use this metric to investigate which specific MATLAB design layers contribute to high complexity in a unit.
Supported Artifacts
This metric collects metric results for Units in the project. To control what the dashboard classifies as a unit, see Categorize Models in Hierarchy as Components or Units.
Computation Details
This metric aggregates measurements from multiple underlying calculations:
Decisions — The metric calculates the number of decisions
in MATLAB code by taking the cyclomatic complexity calculated by the Code Analyzer and
subtracting one to exclude the default path. The metric counts decisions from
if, elseif, while,
for, parfor, try, and
case statements. It ignores else,
otherwise, and catch statements because they form the
default path. For more information, see checkcode and Measure Code Complexity Using Cyclomatic Complexity.
Halstead Difficulty — The metric calculates Halstead difficulty based on the number of total and unique operators and operands in the code. Commented code is ignored, and only code without syntax errors is analyzed.
The metric calculates the Halstead difficulty,
D, using the equation . n1 is the number of unique operators,
N2 is the total number of operands, and n2 is the
number of unique operands.
Collection
To collect data for this metric, execute the metric engine with the metric ID.
metric_engine = metric.Engine;
results = execute(metric_engine,"modeldesign.MATLABMaintainability[slcomp.MATLABDesignDetails]")View the metric result values for a specific unit.
results(1).Value results(1).ScopeAlias
You can also collect all MATLAB maintainability metrics at once by using the group ID.
results = execute(metric_engine,"modeldesign.MATLABMaintainability[]")MetricID property of each result to identify which metric the result
belongs to.Results
The metric returns an array of objects, one for each unit in the project.
Use the metric.ResultValue property of the metric result object to view the metric
result values. Use the ScopeId and ScopeAlias
properties to identify which unit the result belongs to.
The ScopeAlias property returns the name of the unit.
The Value property returns missing when the unit
does not contain any MATLAB design layers. When MATLAB design layers exist, the Value property returns a structure
with these fields:
Decisions— Number of decision points in the design layerELOC— Number of executable lines of codeHalsteadDifficulty— Halstead difficulty scoreTotalOperands— Total number of operandsTotalOperators— Total number of operatorsUniqueOperands— Number of distinct operandsUniqueOperators— Number of distinct operatorsMATLABElement— Structure identifying the design layer, with fields:Alias— Name of the MATLAB design layerURI— Unique resource identifier for the design layer
ELOCBinEdge— The executable lines of code (eLOC) histogram bin that this design layer falls intoDecisionBinEdge— The decision count histogram bin that this design layer falls intoHalsteadDifficultyBinEdge— The Halstead difficulty histogram bin that this design layer falls into