Main Content

getBlock

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

Open the project named ModelReferenceHierarchy.

openProject("ModelReferenceHierarchy");

The project opens a model hierarchy with sldemo_mdlref_depgraph as the top model.

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 at the second level of the model reference hierarchy.

block2 = getBlock(bp,2)
block2 = 
'sldemo_mdlref_heater/Fahrenheit to Celsius'

Get the block at the third level of the model reference hierarchy.

block3 = getBlock(bp,3)
block3 = 
'sldemo_mdlref_F2C/Gain1'

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