Main Content

Maximum Layer Depth

Metric ID



Use this metric to determine the maximum number of layers in the model hierarchy of a unit or component. A layer is a parent or child model component in the model hierarchy.

This metric analyzes these model components:

  • Simulink® Subsystems

  • Stateflow® States

  • MATLAB® Functions

  • MATLAB Methods

Computation Details

The metric:

  • Does not count model references or subsystem references.

  • Does not count relationships to data dictionaries.

  • Does not count relationships to other units. For example, if you have a component with a required relationship to another model that is a unit, that relationship is not included in the metric count. The metric only analyzes the relationship if the other model is not a unit.


To collect data for this metric:

  • In the Model Maintainability Dashboard, in the Component Structure section, point to the Depth widget and click the Run metrics for widget icon. The Depth widget shows the maximum depth found in the current unit or component. If you click on the Depth widget, you can view a table that shows the depth for each model component.

  • Use getMetrics with the metric identifier slcomp.MaxLayerDepth.


For this metric, instances of metric.Result return Value as the maximum number of layers deep a model component is in the model hierarchy for a unit or component.


Suppose you have a unit, u1, that contains only a subsystem, s1, and subsystem s1 contains only subsystem s2. u1 is at layer depth 1, s1 is at layer depth 2, and s2 is at layer depth 3. The maximum layer depth is 3 because 3 is the maximum of the layer depth values associated with the unit. You can view the layer depth associated with each child model component in the Metric Details table by clicking on the Depth widget.

See Also

Related Topics