This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

find_mdlrefs

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

Syntax

[refMdls,mdlBlks] = find_mdlrefs(system)
[refMdls,mdlBlks] = find_mdlrefs(system,Name,Value)
[refMdls,mdlBlks] = find_mdlrefs(system,allLevels)

Description

example

[refMdls,mdlBlks] = find_mdlrefs(system) finds all referenced models and Model blocks contained by the subsystem or model hierarchy that system is the top level of.

[refMdls,mdlBlks] = find_mdlrefs(system,Name,Value) finds referenced models and Model blocks with additional options specified by one or more Name,Value pair arguments.

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

Tip

The find_mdlrefs function 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 in refMdls.

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 a Model block, subsystem, or a model in a model hierarchy.

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

Levels to search, specified as true or false.

  • true — Search all Model blocks 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 of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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

Levels to search, specified as a true or false.

  • true — Search all Model blocks 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 as true or false. This setting does not affect the list of Model blocks returned.

Data Types: logical

Include variant models in search, specified as 'ActivePlusCodeVariants', 'ActiveVariants', or 'AllVariants'.

  • 'ActivePlusCodeVariants' — Include all variant models in Variant Subsystem blocks for which you select the Analyze all choices during update diagram and generate preprocessor conditionals option.

  • 'ActiveVariants' — Include active variant models for Variant Subsystem blocks.

  • 'AllVariants' — Include all variant models in Variant Subsystem blocks.

Include commented blocks in search, specified as false or true.

Data Types: logical

The find_mdlrefs function 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 to true.

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 the system input argument or the parent model of that system.

Names of Model blocks, returned as a cell array of character vectors.

Introduced before R2006a