Documentation

find_mdlrefs

Find Model blocks and referenced models at all levels or at top level only

Syntax

[refMdls, mdlBlks] = find_mdlrefs('modelName')
[refMdls, mdlBlks] = find_mdlrefs('modelName', allLevels)
[refMdls, mdlBlks] = find_mdlrefs('modelName', 'Param1', Val1, ... ,'ParamN', ValN)

Description

[refMdls, mdlBlks] = find_mdlrefs('modelName') finds all Model blocks and referenced models contained by the model hierarchy of which modelName is the top model.

[refMdls, mdlBlks] = find_mdlrefs('modelName', allLevels) If allLevels is true, this is equivalent to the preceding syntax. If allLevels is false, the function searches only the top level of modelName, ignoring any subordinate hierarchy.

[refMdls, mdlBlks] = find_mdlrefs('modelName', 'Param1', Val1, ... ,'ParamN', ValN) searches the model as specified by the optional name/value pairs 'Param1', Val1, ... , 'ParamN', ValN.

Input Arguments

modelName

The model in which to search for Model blocks and referenced models.

allLevels

Boolean specifying whether to search all Model blocks in the modelName model and referenced models contained by the model hierarchy of which modelName is the top model (true) or only the top model modelName (false). Default: true.

'Param1', Val1, ... , 'ParamN', ValN

One or more name/value pairs that control the actions of the function. The possible names and values, and their defaults, are:

'AllLevels'Boolean specifying whether to search the complete hierarchy (true) or only the top level (false). The default if you omit 'AllLevels' is true: the function searches the complete hierarchy of which modelName is the top model.
'IncludeProtectedModels'Boolean that specifies whether the output refMdls includes the names of protected models (true) or excludes them(false). The default if you omit 'IncludeProtectedModels' is false: the function excludes protected models from refMdls.
'Variants'

String that specifies whether the output refMdls includes the names of variant models. The possible values are:

  • 'ActiveVariants' — Include the active variant of each Model Variants block included in the search.

  • 'ActivePlusCodeVariants' — Include all variants for all Model Variants blocks included in the search that have Generate preprocessor conditionals option selected.

  • 'AllVariants' — Include all variants for all Model Variants blocks included in the search.

The default if you omit 'Variants' is 'ActivePlusCodeVariants'.

The find_mdlrefs function provides two different ways to search all levels of the model modelName. Both techniques give the same results, but only the name/value technique allows you to control inclusion of protected and variant models in refMdls.

Output Arguments

mdlBlks

Depending on the value of 'AllLevels', a list containing the names of all Model blocks:

  • In the hierarchy of which modelName is the top model

  • In modelName alone

refMdls

Depending on the value of 'AllLevels', a list containing the names of all models referenced by a Model block:

  • In the hierarchy of which modelName is the top model

  • In modelName alone

Optional inputs to find_mdlrefs control inclusion of protected and variant models. The last element of the refMdls is modelName itself.

Examples

Return in MyMdlBlks the names all Model blocks at the top level of MyModel. Return in MyRefMdls the names of all models referenced by Model blocks at the top level, including the active variant of every variant Model block:

[MyRefMdls, MyMdlBlks] = find_mdlrefs(MyModel, 'AllLevels',...
false, 'Variants', 'ActiveVariants')

See Also

|

Was this topic helpful?