Main Content


Fully specified Simulink block path


A Simulink.BlockPath object represents a fully specified block path that uniquely identifies a block within a model hierarchy, even when the model hierarchy references the same model multiple times.


Use either the Simulink.BlockPath or gcbp function to create a Simulink.BlockPath object. To get a Simulink.BlockPath object for the most recently clicked or loaded block, use the gcbp function.


bp = Simulink.BlockPath creates an empty BlockPath object.

bp = Simulink.BlockPath(blockpath) creates a copy of the specified BlockPath object.


bp = Simulink.BlockPath(paths) creates a BlockPath object from the specified character vector or cell array of character vectors. Each character vector represents a path at a level of the model hierarchy. Simulink® builds the full block path based on the character vectors.

bp = Simulink.BlockPath(paths,subpath) additionally specifies an individual component of the block, such as a signal, that you specify with the subpath argument.

Input Arguments

expand all

Existing BlockPath object that you want to copy, specified as a BlockPath object.

Paths used to build the block path, specified as a character vector or cell array of character vectors.

Specify each character vector in order, from the top model to the specific block for which you are creating a BlockPath object.

Each character vector must be a path to a block within the Simulink model. The block must be:

  • A block in a single model

  • A Model block (except for the last character vector, which may be a block other than a Model block)

  • A block in the model referenced by the Model block that the previous character vector specifies

Individual component of a block, such as a signal, specified as a character vector.


expand all

Component of the block, specified as a character vector that provides the block path. For example, if the block path refers to a Stateflow® chart, you can use SubPath to indicate the chart signals.

Example: 'gear_state.first'

Data Types: char

Object Functions

convertToCellConvert block path to cell array of character vectors
getBlockGet single block path in model reference hierarchy
getLengthGet number of hierarchy levels in block path
openOpen specified model, library, subsystem, or block
validateDetermine whether block path represents valid block hierarchy


collapse all

Open the project named ModelReferenceHierarchy.


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

Create a Simulink.BlockPath object named bp by using a cell array of character vectors that represent elements of the block path.

bp = Simulink.BlockPath(...
    'sldemo_mdlref_heater/Fahrenheit to Celsius',...
bp = 
  Package: Simulink

  Block Path:
      'sldemo_mdlref_heater/Fahrenheit to Celsius'

  Use the getBlock method to access block path character vectors from this object.

The resulting block path identifies the block within the model reference hierarchy.

Version History

Introduced in R2010b