主要内容

可视化模型参考层次结构

此示例显示了如何使用依赖项分析仪查看,探索和分析模型依赖关系。它显示了如何找到引用的模型并与依赖关系图进行交互。

开放型号

Open the example modelsldemo_mdlref_depgraph, which contains multiple referenced models in a model hierarchy.

Find Referenced Models

Use thefind_mdlrefsfunction to programmatically find referenced models and Model blocks. For example, enter this command in the MATLAB Command Window:

[refMdls, modelBlks] = find_mdlrefs('sldemo_mdlref_depgraph')

find_mdlrefs返回两个单元格数组,refMdlsModelblksrefMdls包含直接或间接引用的所有模型的名称sldemo_mdlref_depgraph。By default, the last element inrefMdls是输入模型的名称。Modelblkscontains block paths for all Model blocks in the top model and all referenced models.

View Model Reference Dependency Graph

查看依赖关系图sldemo_mdlref_depgraph模型,执行以下操作之一,以打开模型的依赖项分析仪:

  • Use thedepviewfunction.

  • 在里面Modeling标签,在Design年代ection, clickDependency Analyzer

在依赖关系图中,框代表模型。金宝app箭头表示依赖性。例如,来自sldemo_mdlref_depgraphto年代ldemo_mdlref_house表示这sldemo_mdlref_depgraph参考文献年代ldemo_mdlref_house。If the model references libraries, subsystems, or protected models, the dependency graph shows them in the hierarchy.

In this view, only one box exists for each model in the graph and at most one arrow exists from one box to another box. The dependency graph does not show if multiple references exist from one model to another model. This view does not show which models are referenced in normal mode and which models are referenced in accelerator mode.

Interact with Dependency Graph

  • To select a box, click it.

  • To open the model or library associated with a box, double-click it.

  • To pan the dependency graph, click and hold the mouse wheel button then drag the mouse.

  • To zoom in and out, use the mouse wheel.

  • 要中心依赖关系图并调整缩放,以使依赖关系图填充可用空间,请按空格栏。

查看模型实例依赖图图

To view the referenced model instances in the dependency graph, perform one of these actions:

  • Usedepview('sldemo_mdlref_depgraph','modelReferenceInstance',true)

  • 从依赖分析仪中Views年代ection, selectModel Instances

在里面instance view, the boxes represent Simulink models. The arrows indicate dependencies. The dependency graph shows when multiple references exist from one model to another model. In the instance view, libraries are never shown.

In this view two boxes are labeled年代ldemo_mdlref_F2Cbecause this model is referenced twice, once by年代ldemo_mdlref_outdoor_temp和once by年代ldemo_mdlref_heater。The top model is colored in blue. The red color denotes a normal mode reference, and the yellow color denotes an accelerator mode reference.

年代ldemo_mdlref_heatermakes a normal mode reference to年代ldemo_mdlref_F2C以及加速器模式引用年代ldemo_mdlref_thermostat

Explore Model Instance Views

目前,参考年代ldemo_mdlref_outdoor_tempmakes to年代ldemo_mdlref_F2Cis an accelerator mode reference. Suppose you want to change this reference to be a normal mode reference:

  1. Select the arrow linking年代ldemo_mdlref_outdoor_tempto年代ldemo_mdlref_F2C

  2. 在里面Propertiespane on the right, in the dependency table, click华氏度到摄氏摄氏度。Simulink opens the model年代ldemo_mdlref_outdoor_temp和highlights the Model block named华氏度到摄氏摄氏度。此模型块参考年代ldemo_mdlref_F2C

  3. Select the Model block named华氏度到摄氏摄氏度

  4. 在里面Model Blocktab, change theSimulation ModetoNormal

  5. To see this change, go to the dependency graph and clickAnalyze

The dependency graph now shows the reference年代ldemo_mdlref_outdoor_tempmakes to年代ldemo_mdlref_F2Cas a Normal Mode (Overridden) reference. Note that年代ldemo_mdlref_F2C被配置为以正常模式运行,但其父级年代ldemo_mdlref_outdoor_temp, is configured to run in accelerator mode. Normal mode references from models running in accelerator mode are not supported, so年代ldemo_mdlref_F2Cwill run in accelerator mode during simulation.

To make this model run in normal mode, you must configure all of its ancestors to run in normal mode. To do this:

  1. Select the arrow linkingsldemo_mdlref_depgraphto年代ldemo_mdlref_outdoor_temp

  2. 在里面Propertiespane on the right, in the dependency table, clickoutdoor temp。Simulink opens the modelsldemo_mdlref_depgraph和highlights the Model block namedoutdoor temp。此模型块参考年代ldemo_mdlref_outdoor_temp

  3. Select the Model block namedoutdoor temp

  4. 在里面Model Blocktab, change theSimulation ModetoNormal。(If there were more accelerator mode ancestors of年代ldemo_mdlref_F2C, these would also need to be changed to normal mode references.)

  5. To see this change, go to the dependency graph and clickAnalyze

相关话题