Main Content

getLength

Get number of hierarchy levels in block path

Description

example

length = getLength(bp) returns a numeric value that corresponds to the number of levels in the model reference hierarchy for the block path.

Examples

collapse all

Create a Simulink.BlockPath object that represents a referenced model within a model hierarchy.

load_system('sldemo_mdlref_depgraph')
bp = Simulink.BlockPath({'sldemo_mdlref_depgraph/thermostat', ...
'sldemo_mdlref_heater/Fahrenheit to Celsius'});

Get the number of hierarchy levels in the block path for the Simulink.BlockPath object.

length = getLength(bp)
length =

     2

Input Arguments

collapse all

Fully specified block path, specified as a Simulink.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