主要内容

Simulink.BlockPath

R2026b

Fully specified Simulink block path

Description

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.

Creation

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.

Description

bp = Simulink.BlockPath creates an empty Simulink.BlockPath object.

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

bp = Simulink.BlockPath(paths) creates a Simulink.BlockPath object from the specified paths. Each path represents one block in one model of the model hierarchy.

example

bp = Simulink.BlockPath(paths,subpath) additionally specifies an element of the block, such as a signal, using the subpath argument.

Input Arguments

expand all

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

Hierarchical block paths, specified as a string array, character vector, or cell array of character vectors.

Each path represents one block in one model. Block paths cannot cross model boundaries.

To specify a block in a referenced model, list paths starting with the top model and moving down through the referenced models. Each path except the last must specify a Model block. Each subsequent path must start in the model referenced by the previous one.

Data Types: char | string

Block element, specified as a string or character vector.

For example, if the block path refers to a Stateflow® chart, you can use SubPath to indicate a chart signal.

Data Types: char | string

Properties

expand all

Block element, specified as a string or character vector.

For example, if the block path refers to a Stateflow chart, you can use SubPath to indicate a chart signal.

Example: 'gear_state.first'

Data Types: char | string

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

Examples

collapse all

Open a project that contains a model hierarchy.

openExample("simulink/VisualizeModelReferenceHierarchiesExample")

To uniquely identify a block in the model hierarchy, create a Simulink.BlockPath object using an array that represent the elements of the block path.

bp = Simulink.BlockPath(["sldemo_mdlref_depgraph/thermostat",...
    "sldemo_mdlref_heater/Fahrenheit to Celsius",...
    "sldemo_mdlref_F2C/Gain1"])
bp = 

  Simulink.BlockPath
  Package: Simulink

  Block Path:
    sldemo_mdlref_depgraph/thermostat
      sldemo_mdlref_heater/Fahrenheit to Celsius
        sldemo_mdlref_F2C/Gain1

Version History

Introduced in R2010b