Main Content

getBlock

Get single block path in model reference hierarchy

Description

example

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

Examples

collapse all

Open the example model, which references multiple models.

sldemo_mdlref_depgraph

Create a Simulink.BlockPath object.

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

Get the block for the second level in the model reference hierarchy.

blockpath = getBlock(bp,2)
blockpath =

    'sldemo_mdlref_heater/Fahrenheit to Celsius'

Get the block for the third level in the model reference hierarchy.

blockpath = getBlock(bp,3)
blockpath =

    'sldemo_mdlref_F2C/Gain1'

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.

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.

Introduced in R2010b