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 and Model blocks for all models referenced by the specified model. Include all model reference variants.

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

Simulink.Variant
    Condition: 'E_CTRL==sldemo_mrv_CONTROLLER_TYPE.LINEAR'


VE_NONLINEAR_CONTROLLER =

Simulink.Variant
    Condition: 'E_CTRL==sldemo_mrv_CONTROLLER_TYPE.NONLINEAR'


E_CTRL = 

    LINEAR


VE_PROTOTYPE =

Simulink.Variant
    Condition: 'E_CURRENT_BUILD==sldemo_mrv_BUILD_TYPE.PROTOTYPE'


VE_PRODUCTION =

Simulink.Variant
    Condition: 'E_CURRENT_BUILD==sldemo_mrv_BUILD_TYPE.PRODUCTION'


E_CURRENT_BUILD = 

    PRODUCTION


myModels =

  9×1 cell array

    '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 =

  4×1 cell array

    '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 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 reference hierarchy.

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

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)

collapse all

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

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 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.

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

The find_mdlrefs function loads the models in the model reference 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.

See Also

|

Introduced before R2006a

Was this topic helpful?