coder.codedescriptor.CodeDescriptor.getReferencedModelNames - Return names of referenced models - MATLAB (original) (raw)
Class: coder.codedescriptor.CodeDescriptor
Namespace: coder.codedescriptor
Return names of referenced models
Syntax
refModels = getReferencedModelNames(codeDescObj)
Description
[refModels](#d126e14408) = getReferencedModelNames([codeDescObj](#mw%5Fe5826f10-dccc-46c2-a2bb-d8d9e6e6e0a6))
returns a list of referenced models for acoder.codedescriptor.CodeDescriptor
object. By default, the list includes only the unprotected models that the CodeDescriptor
object directly references. For example, if model1
referencesmodel2
and model2
referencesmodel3
, then running getReferencedModelNames
from the model1
CodeDescriptor
object returns only model2
, notmodel3
. To retrieve different lists of referenced models, use the optional IncludeAllLevels andIncludeProtectedModels parameters.
Input Arguments
coder.codedescriptor.CodeDescriptor
object for which you want to retrieve the information about generated code.
Whether to return the full referenced model hierarchy, specified astrue
or false
. If you set this parameter to true
, the method recursively searches referenced models and returns the full referenced model hierarchy. If you set this parameter to false
or do not specify a value, the method returns only the models that the top model directly references.
Whether to include protected models, specified as true
or false
. If you set this parameter totrue
, the method includes protected models in the list of referenced models. If you set this parameter tofalse
or do not specify a value, the method excludes protected models from the list.
Output Arguments
A list of referenced models.
Examples
Open the model AsynchronousEventsTop
.
openExample('AsynchronousEventsTop');
Build the model.
slbuild('AsynchronousEventsTop');
Create a coder.codedescriptor.CodeDescriptor
object for the model.
codeDescObj = coder.getCodeDescriptor('AsynchronousEventsTop');
Get a list of referenced models included in the model.
getReferencedModelNames(codeDescObj)
ans =
1×1 cell array {'AsynchronousEventsRef'}
Consider this model, myTopModel
, that references a model, myMiddleModel
.
myMiddleModel
contains a reference to another model,myBottomModel
.
If you build myTopModel
and usegetReferencedModelNames
without specifying theIncludeAllLevels parameter, the output includes only myMiddleModel
.
model = "myTopModel"; slbuild(model); codeDescObj = coder.getCodeDescriptor(model); getReferencedModelNames(codeDescObj)
ans =
1x1 cell array
{'myMiddleModel'}
If you set the IncludeAllLevels parameter totrue
, the output also includesmyBottomModel
.
getReferencedModelNames(codeDescObj, IncludeAllLevels = true)
ans =
2x1 cell array
{'myMiddleModel'}
{'myBottomModel'}
Consider this model, myTopModel
, that references a protected model, myProtectedModel
.
If you build the model and use getReferencedModelNames
without specifying the IncludeProtectedModels parameter, the output is empty.
model = "myTopModel"; slbuild(model); codeDescObj = coder.getCodeDescriptor(model); getReferencedModelNames(codeDescObj)
ans =
0x1 empty cell array
If you set the IncludeProtectedModels parameter totrue
, the output includesmyProtectedModel
.
getReferencedModelNames(codeDescObj, IncludeProtectedModels = true)
ans =
1x1 cell array
{'myProtectedModel'}
Version History
Introduced in R2018a