getBlock
Get single block path in model reference hierarchy
Description
Examples
Get Block Path for Specified Model Hierarchy Level
Open the project named ModelReferenceHierarchy
.
openProject("ModelReferenceHierarchy");
The project opens a model hierarchy with sldemo_mdlref_depgraph
as the top model.
Create a Simulink.BlockPath
object.
bp = Simulink.BlockPath(... {'sldemo_mdlref_depgraph/thermostat',... 'sldemo_mdlref_heater/Fahrenheit to Celsius',... 'sldemo_mdlref_F2C/Gain1'});
Get the block at the second level of the model reference hierarchy.
block2 = getBlock(bp,2)
block2 = 'sldemo_mdlref_heater/Fahrenheit to Celsius'
Get the block at the third level of the model reference hierarchy.
block3 = getBlock(bp,3)
block3 = 'sldemo_mdlref_F2C/Gain1'
Input Arguments
bp
— Fully specified block path
Simulink.BlockPath
object | Simulink.SimulationData.BlockPath
object
Fully specified block path, specified as a Simulink.BlockPath
or
Simulink.SimulationData.BlockPath
object. This block path uniquely
identifies a block within a model hierarchy, even when the model hierarchy references
the same model multiple times.
index
— Index of block
integer
Index of the block for which you want to get the block path, specified as an integer. The index reflects the level in the model reference hierarchy. For example:
An index of
1
represents a block in the top model.An index of
2
represents a block in the model that is referenced by the Model block of index1
.An index of
n
represents a block in the model that is referenced by the Model block of indexn-1
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
block
— Block path of block
character vector
Block path of the block at the level of the model reference hierarchy specified by
the index
argument, returned as a character vector.
Version History
Introduced in R2010b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)