Documentation

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)
    example
  • [refMdls,mdlBlks] = find_mdlrefs(system,allLevels)

Description

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

example

[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 and variant models in refMdls.

Examples

collapse all

Find Referenced Models in Model Reference Hierarchy

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

open_system('sldemo_mdlref_variants_enum');
[myModels,myModelBlks] = find_mdlrefs('sldemo_mdlref_variants_enum',...
'AllLevels',true,'Variants','AllVariants')
myModels = 

    'sldemo_mrv_linear_controller'
    'sldemo_mrv_nonlinear_controller'
    'sldemo_mrv_sig_filter1_production'
    'sldemo_mrv_sig_filter1_prototype'
    'sldemo_mrv_sig_filter2_production'
    'sldemo_mrv_sig_filter2_prototype'
    'sldemo_mrv_sig_filter3_production'
    'sldemo_mrv_sig_filter3_prototype'
    'sldemo_mdlref_variants_enum'


myModelBlks = 

    'sldemo_mdlref_variants_enum/Controller'
    'sldemo_mdlref_variants_enum/Filter1'
    'sldemo_mdlref_variants_enum/Filter2'
    'sldemo_mdlref_variants_enum/Filter3'

Related Examples

Input Arguments

collapse all

system — System to searchstring | handle

System to search, specified as a string or a handle.

  • The string can be the path to a Model block, subsystem, or a model in a model reference hierarchy.

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

allLevels — Levels to searchtrue (default) | false

Levels to search, specified as true or false.

  • true — Search all Model blocks in the model reference 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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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

'AllLevels' — Levels to searchtrue (default) | false

Levels to search, specified as a true or false.

  • true — Search all Model blocks in the model reference hierarchy for which the system is the top model.

  • false — Search only the top-level system.

Data Types: logical

'IncludeProtectedModels' — Include protected models in search resultsfalse (default) | true

Include protected models in search, specified as true or false. This setting does not affect the list of Model blocks returned.

Data Types: logical

'Variants' — Include variants in search'ActivePlusCodeVariants' (default) | 'ActiveVariants' | 'AllVariants'

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

  • 'ActivePlusCodeVariants' — Include all variants for Model Variants blocks for which you select the Generate preprocessor conditionals option.

  • 'ActiveVariants' — Include the active variant for Model Variants blocks.

  • 'AllVariants' — Include all variants for Model Variants blocks.

'IncludeCommented' — Include commented blocks in search'off' (default) | 'on'

Include commented blocks in search, specified as 'off' or 'on'.

Output Arguments

collapse all

refMdls — Names of referenced modelscell array of strings

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

mdlBlks — Names of Model blockscell array of strings

Names of Model blocks, returned as a cell array of strings.

More About

See Also

|

Introduced before R2006a

Was this topic helpful?