pathsToReferencedModel
Description
[
finds all referenced models and Model blocks in a model hierarchy starting at
the specified top model and ending at the specified referenced model.models
,blocks
] = pathsToReferencedModel(topModel
,refModel
)
This function uses the find_mdlrefs
function with default options to
populate the model hierarchy.
Examples
Get Paths to Referenced Model
Given a model reference hierarchy, use the pathsToReferencedModel
function to get the models and corresponding Model blocks between a top model and a referenced model.
Open the example project.
openProject("ModelReferenceHierarchy");
A project startup task opens the sldemo_mdlref_depgraph
model, which is the top model in a model hierarchy.
Get the models and corresponding blocks between the sldemo_mdlref_depgraph
top model and the sldemo_mdlref_F2C
referenced model.
topmodel = "sldemo_mdlref_depgraph"; refmodel = "sldemo_mdlref_F2C"; [models,blocks] = pathsToReferencedModel(topmodel,refmodel)
models = 4x1 cell
{'sldemo_mdlref_depgraph' }
{'sldemo_mdlref_outdoor_temp'}
{'sldemo_mdlref_heater' }
{'sldemo_mdlref_F2C' }
blocks = 1x2 BlockPath array with properties: SubPath isLoadingModel isSavingModel
The returned models
array includes four models, including the specified top and bottom models.
The returned blocks
array includes one Simulink.BlockPath
object for each instance of the referenced model. Based on dimensions of the array, the model hierarchy references the sldemo_mdlref_F2C
model twice.
Inspect the first Simulink.BlockPath
object.
blocks(1)
ans = Simulink.BlockPath Package: Simulink Block Path: 'sldemo_mdlref_depgraph/outdoor temp' 'sldemo_mdlref_outdoor_temp/Fahrenheit to Celsius' Use the getBlock method to access block path character vectors from this object.
Each Model block in the block path is given relative to its parent model.
The
sldemo_mdlref_depgraph
model contains a Model block namedoutdoor temp
.The referenced
sldemo_mdlref_outdoor_temp
model contains a Model block namedFahrenheit to Celsius
. As the last Model block in the path, this Model block references thesldemo_mdlref_F2C
model.
Inspect the second Simulink.BlockPath
object.
blocks(2)
ans = Simulink.BlockPath Package: Simulink Block Path: 'sldemo_mdlref_depgraph/thermostat' 'sldemo_mdlref_heater/Fahrenheit to Celsius' Use the getBlock method to access block path character vectors from this object.
Each Model block in the block path is given relative to its parent model.
The
sldemo_mdlref_depgraph
model contains a Model block namedthermostat
.The referenced
sldemo_mdlref_heater
model contains a Model block namedFahrenheit to Celsius
. As the last Model block in the path, this Model block references thesldemo_mdlref_F2C
model.
Input Arguments
topModel
— Name of top model
character vector | string scalar
Name of top model, specified as a character vector or string scalar.
Data Types: char
| string
refModel
— Name of referenced model
character vector | string scalar
Name of referenced model, specified as a character vector or string scalar.
Data Types: char
| string
Output Arguments
models
— Models in path
cell array of character vectors
Models in path, returned as a cell array of character vectors.
The array includes the model name as a character vector for:
The specified top model
Each model between the specified top model and the specified referenced model
The specified referenced model
blocks
— Model blocks in path
array of Simulink.BlockPath
objects
Model blocks in path, returned as an array of
Simulink.BlockPath
objects.
Each Model block between the specified top model and the specified
referenced model is identified by a Simulink.BlockPath
object.
Version History
Introduced in R2023b
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
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)