Main Content

getBlock

R2026b

Get single block path in model reference hierarchy

Description

block = getBlock(bp,index) returns the block path of the block at the level of the model reference hierarchy specified by the index argument.

example

Examples

collapse all

Suppose you have a Simulink.BlockPath object named bp that represents a Model block in a model hierarchy. Each level of the block path represents a Model block.

Get the Model block at the first level of the block path specified by bp.

blk = getBlock(bp,1)
blk =

    'sldemo_mdlref_depgraph/thermostat'

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.

Index of the block for which you want to get the block path, specified as an integer. The index reflects the level in the model reference hierarchy. For example:

  • An index of 1 represents a block in the top model.

  • An index of 2 represents a block in the model that is referenced by the Model block of index 1.

  • An index of n represents a block in the model that is referenced by the Model block of index n-1.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Block path of the block at the level of the model reference hierarchy specified by the index argument, returned as a character vector.

Version History

Introduced in R2010b