人在仿真软件金宝app

金宝app仿真软件和基于模型的设计

Subsystem the Reference and Test Harness

In case you missed it, some time I demonstrate a line 这篇文章 介绍了 子系统的参考 . I really like this feature and the way it allows you to simple store the contents of a Subsystem in a separate file.
在R2019b首次发布以来,很多已经增强子系统参考和今天我想强调一个我觉得特别有用: The Test Harnesses

The Challenge

One recommendation I always difference to users devel金宝appoping Simulink models is to try keeping the model in an "updatable" state as much as possible. This mostly means doing Update the diagram , (Shortcut: Ctrl + D ). That way, if you make a mistake, you will quickly get the an error describing what is wrong. Without That, if you make multiple changes before trying to update the model, the error messages took be more about the debug because there can be a combination of multiple system - related issues.
A Reference Subsystem can be edited in two ways, and both have caveats regarding the above the suggestion:
  • Editing standalone.Since a Subsystem file does not have a complete configuration set, it is not possible to perform an update diagram on a standalone Subsystem.
  • Editing the an instance in a model:在一个模型中,可以编辑子系统,点击Ctrl + D来验证您的更改。这种方法的一个可能的挑战是,如果模型很大,包含许多块修改子系统,执行一个更新图可能需要时间。
Let 's see how a test harness can help with that.

Creating a Default Test Harness

从MATLAB R2020b开始,一个子系统的子系统选项卡引用文件有一个新的测试工具部分允许您创建测试:
我不打算在这篇文章中描述为什么它总是一个好主意来创建模型和子系统测试,您可以访问 引入测试文档页面 To read more on that topic.
What I want to point out in this post is that, with a test harness, we now have a context in which the subsystem can be simulated.

The Update With the Test Harness

一次测试工具被添加到一个子系统文件, The Update With the Test Harness The action becomes available and is associated with the same shortcut as a model (in Ctrl + D ).
This means that when you edit the Subsystem standalone, you will be able to frequently hit Ctrl + D and keep the Subsystem in an updatable state. Under the hood, we will accomplish differ the update diagram using the test harness, so if there are no errors, you don 't have to explicitly open the test harness.
如果有一个错误,它将报告的诊断与超链接查看器有问题的街区环境的利用。

模拟与测试工具

以类似的方式,我们还添加了一个“ Run with the Test Harness "Button to the toolstrip. Using this button, the Subsystem is simulated with the default harness, and you can visualize the logged data in the Simulation data of Inspector.

现在轮到你了

You leveraging test harnesses with Subsystem Reference?If yes, are you taking advantage of those to ensure that your Subsystem remains "updatable and validate simulation results in a default test harness?
尝试这个功能,在下面的评论中让我们知道你的想法。
|

comments

To comment, please clickhere登录到您的MathWorks帐户或创建一个新帐户。