Main Content

Stateflow Decision Distribution

R2026b
Since R2026b

Metric ID

modeldesign.StateflowMaintainability[slcomp.DecisionDistribution]

Description

This metric returns a histogram showing how many Stateflow® design layers in each unit fall into each decision count range. Decisions are branch points in Stateflow charts, such as conditions on transitions and decision junctions. Use this metric to identify units where Stateflow design layers have high decision complexity.

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.

Decision Counts for Stateflow Components

The metric returns both graphical decisions and code decisions. Graphical decisions are decisions based on the graphical connections in the Stateflow chart. Code decisions are decisions based on the code written in MATLAB® or C, depending on the action language of the Stateflow chart.

This table shows how the metric calculates the decision count for Stateflow components.

ComponentGraphical Decision CountCode Decision Count
Transitions

Number of transitions with conditions or non-empty triggers

Number of short-circuit operations (&& and ||) in conditions

States

Number of states minus the default state

Number of MATLAB decisions in entry, during, and exit actions

Truth Tables

Number of conditions multiplied by the number of decisions in the Condition Table

Number of code decisions in the Action Table

Computation Details

This metric is a heuristic that estimates the number of Stateflow decisions. The calculated decision count is not exact.

The metric:

  • Does not compile the model. The metric only considers static information.

  • Ignores Stateflow states and transitions that have syntax errors.

  • Ignores transitions with empty triggers.

  • Ignores trigger statements that are commented out or only contain '?'.

  • Ignores commented out Stateflow objects.

The metric aligns with the decision coverage returned by Simulink® Coverage™. For information, see Model Coverage for Stateflow Charts (Simulink Coverage).

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.DecisionDistribution]")

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[]")
Use the MetricID property of each result to identify which metric the result belongs to.

Results

The metric returns an array of metric.Result objects, one for each unit in the project. Use the Value 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 an array of structures representing a histogram. Each structure has these fields:

  • BinEdge — The decision count range for the bin, such as '0-9' or '>99'

  • BinCount — The number of Stateflow design layers in the unit whose decision count falls within this range

See Also

Topics