本页面提供的是上一版软件的文档。当前版本中已删除对应的英文页面。
配平和线性化 Simulink 模型
此示例说明如何以编程方式线性化 Simulink 模型 watertank 反馈控制系统。此示例中,您可获得在水箱水位处于稳态的工作点处线性化的水箱系统开环模型。
有关如何以编程方式指定输入和输出点以线性化模型的详细信息,请参阅指定要线性化的模型部分 和 Specify Portion of Model to Linearize at Command Line。
有关找出线性化工作点的详细信息,请参阅根据设定计算稳态工作点 和 Compute Operating Points from Specifications at the Command Line。
打开模型。
mdl = 'watertank';
open_system(mdl)
在此模型中,当水位处于 H
= 10
时,存在一个预期的稳态工况。
计算工作点
要线性化模型,您必须首先获得表示线性化该模型时所处工况的工作点。一种方法是首先仿真模型,并在仿真接近于所需值时提取工作点。然后,您可以将此工作点作为起点,执行基于优化的搜索(配平)以找到稳态工作点。
使用 findop
函数仿真模型,并在 10
秒后使用模型工况获得工作点。
opsim = findop(mdl,10)
opsim = Operating point for the Model watertank. (Time-Varying Components Evaluated at time t=10) States: ---------- x _______ (1.) watertank/PID Controller/Integrator/Continuous/Integrator 1.6949 (2.) watertank/Water-Tank System/H 10.0796 Inputs: None ----------
在此工作点中,H
不等于所需值 10
。但是,您可以使用此工作点来初始化对 H
= 10
处的工作点的搜索。
要配置工作点搜索,请先创建一个工作点设定对象。
opspec = operspec(mdl);
使用工作点 opsim
中的状态值初始化工作点设定中的状态值。
opspec = initopspec(opspec,opsim);
使用工作点设定配平模型。
opss = findop(mdl,opspec);
Operating point search report: --------------------------------- opreport = Operating point search report for the Model watertank. (Time-Varying Components Evaluated at time t=10) Operating point specifications were successfully met. States: ---------- Min x Max dxMin dx dxMax ___________ ___________ ___________ ___________ ___________ ___________ (1.) watertank/PID Controller/Integrator/Continuous/Integrator -Inf 1.2649 Inf 0 0 0 (2.) watertank/Water-Tank System/H 0 10 Inf 0 -1.0991e-14 0 Inputs: None ---------- Outputs: None ----------
在此工作点中,H
= 10
,与预期相符。工作点处于稳态,因为模型状态的 dx
值接近于零。
配置线性分析点
要线性化模型,必须指定要线性化的模型部分。线性分析点指定了线性化模型的输入和输出。要提取水箱被控对象的开环线性化模型,请在 Controller 模块的输出端添加一个输入点,并在 Water-Tank System 模块的输出端添加一个具有环路开口的输出点。
指定输入点。
watertank_io(1) = linio('watertank/PID Controller',1,'input');
指定具有环路开口的输出点。
watertank_io(2) = linio('watertank/Water-Tank System',1,'openoutput');
线性化和分析模型
现在,您可以使用指定的工作点和线性分析点来线性化模型。
sys = linearize(mdl,opss,watertank_io);
生成的模型是一个状态空间对象,您可以使用 Control System Toolbox™ 软件中的任何工具对其进行分析。例如,查看线性模型的频率响应。
bode(sys)
关闭 Simulink® 模型。
bdclose(mdl)