Stateflow Design Details
R2026bMetric ID
modeldesign.StateflowMaintainability[slcomp.StateflowDesignDetails]
Description
This metric returns detailed maintainability measurements for each Stateflow® design layer in a unit. The measurements include state count, transition count, decision count, Halstead difficulty, effective lines of code, and the graphical and code operator and operand counts used to compute Halstead difficulty. Use this metric to investigate which specific Stateflow 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 is a heuristic that estimates the
number of Stateflow decisions. The metric returns both graphical decisions (based on graphical
connections in the chart) and code decisions (based on the action language code). Graphical
decisions count transitions with conditions or non-empty triggers and states minus the default
state. Code decisions count MATLAB® decisions in entry, during, and exit actions and short-circuit operations
(&& and ||) in transition conditions. The
metric ignores states and transitions with syntax errors, transitions with empty triggers, and
commented out objects.
Halstead Difficulty — The metric calculates Halstead difficulty based on the number of total and unique operators and operands across both the Stateflow graphical elements and MATLAB action code. Commented objects and unresolved symbols are ignored.
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.StateflowMaintainability[slcomp.StateflowDesignDetails]")View the metric result values for a specific unit.
results(1).Value results(1).ScopeAlias
You can also collect all Stateflow maintainability metrics at once by using the group ID.
results = execute(metric_engine,"modeldesign.StateflowMaintainability[]")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 Stateflow design layers. When Stateflow design layers exist, the Value property returns one
structure per design layer. Each structure has these fields:
CodeDecisions— Number of decision points in the action codeCodeTotalOperands— Total number of operands in the action codeCodeTotalOperators— Total number of operators in the action codeCodeUniqueOperands— Number of distinct operands in the action codeCodeUniqueOperators— Number of distinct operators in the action codeEffectiveLinesOfCode— Number of effective lines of code in the design layerGraphicalDecisions— Number of graphical decision points in the chartGraphicalTotalOperands— Total number of graphical operandsGraphicalTotalOperators— Total number of graphical operatorsGraphicalUniqueOperands— Number of distinct graphical operandsGraphicalUniqueOperators— Number of distinct graphical operatorsHalsteadDifficulty— Halstead difficulty scoreStates— Number of states in the design layerTransitions— Number of transitions in the design layerStateflowElement— Structure identifying the design layer, with fields:Alias— Name of the Stateflow design layerURI— Unique resource identifier for the design layer
Decisions— Total number of decision points (code and graphical combined)StateBinEdge— The state count histogram bin that this design layer falls intoTransitionBinEdge— The transition count 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