使用实时编辑器任务的交互式控件设计
Melda Ulusoy, MathWorks
Live Editor任务是可以添加到Live脚本中的应用程序,无需编写任何代码即可完成一组不同的操作。本视频将带您通过使用Live Editor任务从测量的植物数据设计控制器。您将学习如何从测量数据中交互式地估计状态空间模型,对识别的模型进行离散化,最后,设计一个PID控制器,这一切都在一个地方:您的实时脚本。
在19b中,我们介绍了Live Editor任务,这些应用程序可以添加到实时脚本中,以执行特定的操作集。假设这是你需要遵循的工作流程,从测量的工厂数据设计控制器。Live Editor任务允许您在一个地方完成所有工作流步骤,节省您的时间并消除编写代码的需要。让我们看看如何使用这些Live Editor任务从测量的植物数据估计状态空间模型,对识别的模型进行离散化,然后为离散化的植物设计控制器。
这里的代码加载和绘制测量的植物数据。您可以在内联或在脚本的右侧显示此代码的输出。为了完成这个工作流的第一步,我们将使用估计状态空间模型任务。要找到这个任务,我们将转到Live Editor选项卡并单击task。在这里,您可以找到来自不同工具箱的Live Editor任务。这是我们需要的。让我们把它插入到我们的实时脚本中。正如您在这里看到的,Live Editor任务允许您以交互方式指定参数。当您选择数据时,它会自动从MATLAB工作区中找到您可以在下拉菜单中选择的适当的预定义变量。通过单击此圆形图标,您可以使任务自动运行,并在每次调整任务中的值时更新和显示结果。 If you don’t have the knowledge of the plant order, you can simply try out different values. Since the task is running automatically, when you change the plant order, you’ll see updated results on the right. The increased order of 5 didn’t improve the estimation fit much. So let’s set the order back to 4. If you want, you can rename the identified model in this field here. Using the task, we easily estimated a model from measured data without writing any code. If you want to see the MATLAB commands that are used by this task, you can display them by clicking the arrow on the bottom of the task. You can also enable this feature from the options menu by selecting “controls and code.” This task also lets you adjust parameters of the estimation algorithm, such as the search method and maximum iterations. As we change some of the parameters here, you see how the appropriate arguments are automatically called by these functions. This saves you time and eliminates the need to search for the specific MATLAB functions and the different options they can be set up with.
现在,我们将继续进行工作流的第二步,将识别的模型离散化。为此,我们将使用转换模型速率任务。如果您已经知道要使用的任务的名称,那么只需在活动脚本中输入它的名称,并通过从建议列表中选择任务来添加任务。在选择模型并指定控制器的采样时间之后,您可以尝试不同的转换方法,以找到在原始模型和转换后的模型之间更好匹配的方法。
最后一步是设计离散化装置的PID控制器。为此,我们将在Control System Toolbox中添加这个任务。选择离散化设备后,可以对不同的控制器设置进行实验,如自由度和控制器类型。然后你可以通过使用这些滑块微调你的控制器,它可以帮助你改变参考跟踪和干扰抑制之间的平衡。通过勾选此框,还可以显示系统响应特性,如上升时间和超调量,并确保控制器满足您的设计要求。
如果你想与他人分享你的工作,你可以简单地与他们分享这个实时脚本,他们可以使用不同的参数来想出新的控制器设计。或者,您可以通过在每个任务上选择此选项来隐藏交互用户界面,然后共享生成的代码。
有关Live Editor任务的更多信息,请参阅文档。
您也可以从以下列表中选择网站:
如何获得最佳的网站性能
选择中国网站(中文或英文)以获得最佳的网站表现。其他MathWorks国家网站没有针对从您的位置访问进行优化。