Main Content


Fully specified block path


A Simulink.SimulationData.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. A Simulink.SimulationData.BlockPath object is very similar to a Simulink.BlockPath object. However, you do not need to have Simulink® installed to use Simulink.SimulationData.BlockPath objects.


The software creates Simulink.SimulationData.BlockPath objects when creating Simulink.SimulationData.Dataset objects for logging simulation data such as signal data or state data. For example, signal logging information is stored in Simulink.SimulationData.Signal objects that each have a BlockPath parameter that contains a Simulink.SimulationData.BlockPath object that fully specifies the block path for the logged signal.


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

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


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

bp = Simulink.BlockPath(paths,subpath) specifies an individual component of the block, such as a signal, in the subpath argument.

Input Arguments

expand all

Existing block path that you want to copy, specified as a Simulink.SimulationData.BlockPath or Simulink.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'

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


collapse all

Open the model sldemo_mdlref_basic, which contains three Model blocks: CounterA, CounterB, and CounterC. The Model blocks reference the same model reference, sldemo_mdlref_counter.

mdl = "sldemo_mdlref_basic";

The sldemo_mdlref_basic model

Create a Simulink.SimulationData.BlockPath object named bpSD that gives the fully specified path to the Switch block in the referenced model CounterA using a cell array of character vectors that represent elements of the block path.

bpSD = Simulink.SimulationData.BlockPath(...
bpSD = 
  Package: Simulink.SimulationData

  Block Path:

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

The model ThreeSigs logs data from a Sine Wave block, a Random Number block, and a Constant block. Simulate the model.

mdl = "ThreeSigs";
out = sim(mdl);

The ThreeSigs model

By default, all logged data is contained in a Simulink.SimulationOutput object named out. Output data is grouped in a Simulink.SimulationData.Dataset object named yout. Use dot notation to access the logged output data.

loggedSigs = out.yout
loggedSigs = 
Simulink.SimulationData.Dataset 'yout' with 3 elements

                         Name      BlockPath      
                         ________  ______________ 
    1  [1x1 Signal]      sineSig   ThreeSigs/Out1
    2  [1x1 Signal]      randSig   ThreeSigs/Out2
    3  [1x1 Signal]      constSig  ThreeSigs/Out3

  - Use braces { } to access, modify, or add elements using index.

The fully specified block path for each signal is located in the BlockPath parameter of the corresponding Signal object. For example, use curly braces to access the randSig element of the output Dataset object using the index 2. Then, access the Simulink.SimulationData.BlockPath object associated with randSig.

sig2 = loggedSigs{2};
ans = 
  Package: Simulink.SimulationData

  Block Path:

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

Version History

Introduced in R2012b