主要内容

getLength

R2026b

Get number of hierarchy levels in block path

Description

length = getLength(bp) returns the number of levels in the model reference hierarchy for the block path.

example

Examples

collapse all

Suppose you have a Simulink.BlockPath object named bp that represents a Model block in a model hierarchy.

Get the number of hierarchy levels in the block path specified by bp.

length = getLength(bp)
length = 
2

For information on how to create a Simulink.BlockPath object, see Simulink.BlockPath.

Input Arguments

collapse all

Fully specified block path, specified as a Simulink.BlockPath or Simulink.SimulationData.BlockPath object. This block path uniquely identifies a block within a model hierarchy, even when the model hierarchy references the same model multiple times.

Output Arguments

collapse all

Length of the block path, returned as an integer. The length is the number of levels in the model reference hierarchy.

Version History

Introduced in R2010b