Main Content

Simulink Design Details

R2026b
Since R2026b

Metric ID

modeldesign.SimulinkMaintainability[slcomp.SimulinkDesignDetails]

Description

This metric returns detailed maintainability measurements for each Simulink® design layer in a unit. The measurements include block count, signal line count, Goto block count, decision count, Halstead difficulty, and the operator and operand counts used to compute Halstead difficulty. Use this metric to investigate which specific Simulink 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 Simulink decisions. The calculated decision count is not exact. The metric includes active and inactive variants, does not include commented blocks, does not compile the model, and does not resolve parameters. For the decision count for specific block types, see Decision Counts for Common Block Types.

Halstead Difficulty — The metric calculates Halstead difficulty based on the number of total and unique operators and operands in the design layer. For Simulink models, an operator is each block (including library blocks and user libraries) and an operand is each port handle. Commented blocks are ignored.

The metric calculates the Halstead difficulty, D, using the equation D=n12×N2n2. 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.SimulinkMaintainability[slcomp.SimulinkDesignDetails]")

View the metric result values for a specific unit.

results(1).Value
results(1).ScopeAlias

You can also collect all Simulink maintainability metrics at once by using the group ID.

results = execute(metric_engine,"modeldesign.SimulinkMaintainability[]")
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 one structure per Simulink design layer in the unit. Each structure has these fields:

  • Blocks — Number of blocks in the design layer

  • Decisions — Number of decision points in the design layer

  • Gotos — Number of Goto blocks in the design layer

  • HalsteadDifficulty — Halstead difficulty score

  • Inports — Number of input ports on the design layer

  • Outports — Number of output ports on the design layer

  • SignalLines — Number of signal lines in the design layer

  • TotalOperands — Total number of operands

  • TotalOperators — Total number of operators

  • UniqueOperands — Number of distinct operands

  • UniqueOperators — Number of distinct operators

  • SimulinkElement — Structure identifying the design layer, with fields:

    • Alias — Name of the Simulink design layer

    • URI — Unique resource identifier for the design layer

  • BlockBinEdge — The block count histogram bin that this design layer falls into

  • SignalLineBinEdge — The signal line count histogram bin that this design layer falls into

  • GotoBinEdge — The Goto block count histogram bin that this design layer falls into

  • DecisionBinEdge — The decision count histogram bin that this design layer falls into

  • HalsteadDifficultyBinEdge — The Halstead difficulty histogram bin that this design layer falls into

See Also

Topics