Documentation

find_mdlrefs

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

Description

example

[refMdls,mdlBlks] = find_mdlrefs(system)finds all referenced models andModelblocks contained by the subsystem or model hierarchy thatsystemis the top level of.

[refMdls,mdlBlks] = find_mdlrefs(system,Name,Value)finds referenced models andModelblocks with additional options specified by one or moreName,Valuepair arguments.

[refMdls,mdlBlks] = find_mdlrefs(system,allLevels)specifies the levels of the system to search.

Tip

Thefind_mdlrefsfunction provides two different ways to specify the levels of the system to search. Both techniques give the same results, but only the name and value technique allows you to control inclusion of protected models inrefMdls.

Examples

collapse all

Find referenced models and Model blocks for all models referenced by the specified model.

load_system('sldemo_mdlref_basic'); [myModels,myModelBlks] = find_mdlrefs('sldemo_mdlref_basic')
myModels =2x1 cell array{'sldemo_mdlref_counter'} {'sldemo_mdlref_basic' }
myModelBlks =3x1 cell array{'sldemo_mdlref_basic/CounterA'} {'sldemo_mdlref_basic/CounterB'} {'sldemo_mdlref_basic/CounterC'}

Input Arguments

collapse all

System to search, specified as a character vector or a handle.

  • The character vector can be the path to aModelblock, subsystem, or a model in a model hierarchy.

  • The handle can be for aModelblock, subsystem, or model in a model hierarchy.

Levels to search, specified astrueorfalse.

  • true— Search allModelblocks in the model hierarchy for which the system is the top model.

  • false— Search only the top-level system.

Data Types:logical

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

Example:refModels =find_mdlrefs(top_model,'IncludeProtectedModels',true)

Levels to search, specified as atrueorfalse.

  • true— Search allModelblocks in the model hierarchy for which the system is the top model.

  • false— Search only the top-level system.

Data Types:logical

Include protected models in search, specified astrueorfalse. This setting does not affect the list ofModelblocks returned.

Data Types:logical

包括变体模型搜索,指定为'ActivePlusCodeVariants','ActiveVariants', or'AllVariants'.

  • 'ActivePlusCodeVariants'— Include all variant models inVariant Subsystemblocks for which you select theAnalyze all choices during update diagram and generate preprocessor conditionalsoption.

  • 'ActiveVariants'— Include active variant models forVariant Subsystemblocks.

  • 'AllVariants'— Include all variant models inVariant Subsystemblocks.

Include commented blocks in search, specified asfalseortrue.

Data Types:logical

Thefind_mdlrefsfunction loads the models in the model hierarchy of the model that you specify. By default, the function closes those models, except for models that were already loaded before execution of the function. To keep all the models loaded that the function loads, set this argument totrue.

Data Types:logical

Output Arguments

collapse all

Names of referenced models, returned as a cell array of character vectors. The last element is the system you specified in thesysteminput argument or the parent model of that system.

Names ofModelblocks, returned as a cell array of character vectors.

Introduced before R2006a