Simulink.SimulationData.BlockPath - Fully specified block path - MATLAB (original) (raw)
Main Content
Fully specified block path
Description
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. ASimulink.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.
Creation
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 inSimulink.SimulationData.Signal
objects that each have aBlockPath parameter that contains aSimulink.SimulationData.BlockPath
object that fully specifies the block path for the logged signal.
Syntax
Description
`bp` = Simulink.SimulationData.BlockPath
creates an empty Simulink.SimulationData.BlockPath
object.
`bp` = Simulink.BlockPath([blockpath](#mw%5F8bc1af57-40a2-48cf-9c72-b3d1f22feed4))
creates a copy of the BlockPath
object specified byblockpath
.
`bp` = Simulink.BlockPath([paths](#mw%5Fbd96eda7-8b64-43b7-8750-c1e6204af333))
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](#mw%5Fbd96eda7-8b64-43b7-8750-c1e6204af333),[subpath](#mw%5F7d364426-2cc4-456d-bde0-6b4b75647e7d))
specifies an individual component of the block, such as a signal, in thesubpath
argument.
Input Arguments
Existing block path that you want to copy, specified as aSimulink.SimulationData.BlockPath
orSimulink.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.
Properties
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
convertToCell | Convert block path to cell array of character vectors |
---|---|
getBlock | Get single block path in model reference hierarchy |
getLength | Get number of hierarchy levels in block path |
Examples
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"; open_system(mdl)
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(... {'sldemo_mdlref_basic/CounterA',... 'sldemo_mdlref_counter/Switch'})
bpSD = Simulink.SimulationData.BlockPath Package: Simulink.SimulationData
Block Path: sldemo_mdlref_basic/CounterA sldemo_mdlref_counter/Switch
Use the getBlock method to access block path strings from this object.
Methods
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);
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 = 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}; sig2.BlockPath
ans = Simulink.SimulationData.BlockPath Package: Simulink.SimulationData
Block Path: ThreeSigs/Out2
Use the getBlock method to access block path strings from this object.
Methods
Version History
Introduced in R2012b