Simulink.SimulationData.BlockPath class
Package: Simulink.SimulationData
Fully specified Simulink block path
Description
Simulink® creates block path objects when creating dataset objects for signal logging and
data store logging. Simulink.SimulationData.Signal
and
Simulink.SimulationData.DataStoreMemory
objects include block path
objects.
You can create a block path that you can use with the getElement
method
to access a specific dataset element. If you want to create a dataset in MATLAB to use as a
baseline to compare against a signal logging or data store logging dataset, then you need to
create the block paths as part of that dataset.
The Simulink.SimulationData.BlockPath
class is very similar to the
Simulink.BlockPath
class.
You do not have to have Simulink installed to use the Simulink.SimulationData.BlockPath
class.
However, you must have Simulink installed to use the Simulink.BlockPath
class. If you have
Simulink installed, consider using Simulink.BlockPath
instead of
Simulink.SimulationData.BlockPath
, because the
Simulink.BlockPath
class includes a method for checking the validity of
block path objects without you having to update the model diagram.
Property Summary
Name | Description |
---|---|
Individual component within the block specified by the block path |
Method Summary
Name | Description |
---|---|
Create a block path. | |
Convert a block path to a cell array of character vectors. | |
Get a single block path in the model reference hierarchy. | |
Get the length of the block path. |
Properties
SubPath
Represents an individual component within the block specified by the block path.
For example, if the block path refers to a Stateflow® chart, you can use SubPath
to indicate the chart signals.
For example:
Block Path: 'sf_car/shift_logic' SubPath: 'gear_state.first'
character vector
RW
Methods
BlockPath
Create block path
blockpath_object = Simulink.SimulationData.BlockPath() blockpath_object = Simulink.SimulationData.BlockPath(blockpath) blockpath_object = Simulink.SimulationData.BlockPath(paths) blockpath_object = Simulink.SimulationData.BlockPath(paths, subpath)
blockpath
The block path object that you want to copy.
paths
A character vector or cell array of character vectors that Simulink uses to build the block path.
Specify each character vector in order, from the top model to the specific block for which you are creating a block path.
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 that is in a model that is referenced by a Model block that is specified in the previous character vector
subpath
A character vector that represents an individual component within a block.
blockpath_object
The block path that you create.
blockpath_object = Simulink.SimulationData.BlockPath()
creates an
empty block path.
blockpath_object = Simulink.SimulationData.BlockPath(
creates a copy of the block path of the block path object that you specify with the
blockpath
)source_blockpath
argument.
blockpath = Simulink.SimulationData.BlockPath(
creates a block path from the character vector or cell array of character vectors that you
specify with the paths
)paths
argument. Each character vector represents a
path at a level of model hierarchy.
blockpath = Simulink.SimulationData.BlockPath(
creates a block path from the character vector or cell array of character vectors that you
specify with the paths
, subpath
)paths
argument and creates a path for the individual
component (for example, a signal) of the block.
Create a block path object called bp1
, using a cell array of
character vectors representing elements of the block path.
bp1 = Simulink.SimulationData.BlockPath(... {'sldemo_mdlref_depgraph/thermostat', ... 'sldemo_mdlref_heater/Fahrenheit to Celsius', ... 'sldemo_mdlref_F2C/Gain1'})
The resulting block path reflects the model reference hierarchy for the block path.
bp1 = Simulink.BlockPath Package: Simulink Block Path: 'sldemo_mdlref_depgraph/thermostat' 'sldemo_mdlref_heater/Fahrenheit to Celsius' 'sldemo_mdlref_F2C/Gain1
convertToCell
Convert block path to cell array of character vectors
cellarray = blockPathObject.convertToCell()
cellarray
The cell array of character vectors representing the elements of the block path.
cellarray = blockPathObject.convertToCell()
converts a block path
to a cell array of character vectors.
bp1 = Simulink.SimulationData.BlockPath(... {'sldemo_mdlref_depgraph/thermostat', ... 'sldemo_mdlref_heater/Fahrenheit to Celsius', ... 'sldemo_mdlref_F2C/Gain1'}) cellarray_for_bp1 = bp1.convertToCell()
The result is a cell array representing the elements of the block path.
cellarray_for_bp1 = 'sldemo_mdlref_depgraph/thermostat' 'sldemo_mdlref_heater/Fahrenheit to Celsius' 'sldemo_mdlref_F2C/Gain1'
getBlock
Get single block path in model reference hierarchy
block = blockPathObject.getBlock(index)
index
The index of the block for which you want to get the block path. The index reflects the level in the model reference hierarchy. An index of 1 represents a block in the top-level model, an index of 2 represents a block in a model referenced by the block of index 1, and an index of
n
represents a block that the block with indexn-1
references.
block
The block representing the level in the model reference hierarchy specified by the
index
argument.
blockpath = Simulink.SimulationData.BlockPath.getBlock(
returns the block path of the block specified by the index
)index
argument.
Get the block for the second level in the model reference hierarchy.
bp1 = Simulink.SimulationData.BlockPath(... {'sldemo_mdlref_depgraph/thermostat', ... 'sldemo_mdlref_heater/Fahrenheit to Celsius', ... 'sldemo_mdlref_F2C/Gain1'}) blockpath = bp1.getBlock(2)
The result is the thermostat
block, which is at the second level
in the block path hierarchy.
blockpath = sldemo_mdlref_heater/Fahrenheit to Celsius
getLength
Get length of block path
length = blockPathObject.getLength()
length
The length of the block path. The length is the number of levels in the model reference hierarchy.
length = Simulink.SimulationData.BlockPath.getLength()
returns a
numeric value that corresponds to the number of levels in the model reference hierarchy
for the block path.
Get the length of block path bp1
.
bp1 = Simulink.SimulationData.BlockPath(... {'sldemo_mdlref_depgraph/thermostat', ... 'sldemo_mdlref_heater/Fahrenheit to Celsius', ... 'sldemo_mdlref_F2C/Gain1'}) length_bp1 = bp1.getLength()
The result reflects that the block path has three elements.
length_bp1 = 3
Version History
Introduced in R2012b