matlab求解时变系统的Riccati矩阵微分方程

这篇具有很好参考价值的文章主要介绍了matlab求解时变系统的Riccati矩阵微分方程。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

对于代数Riccati方程的求解网上能找到很多的资源,matlab也有成熟的函数,但是对于时变系统的Riccati矩阵微分方程,能找到的资料还比较少。

一、求解代数Riccati方程

可以在网上找到很多资料,如

  • https://blog.csdn.net/m0_62299908/article/details/127807014

matlab也有相应的一系列函数 lqr、icare等。
对于这些函数不同的适用范围自己目前了解的还不够,之后补上。
这些函数到底能不能用于求解时变系统自己还没搞清楚。

二、如何处理时变系统

参见matlab官方论坛 Solving Riccati differential equation with time variable matrix
这个帖子给出的方案是ode45中有一个关于处理时变项的例子。
matlab求解时变系统的Riccati矩阵微分方程,matlab,控制,matlab

matlab求解时变系统的Riccati矩阵微分方程,matlab,控制,matlab

matlab的 ode45 函数官方文档的例子中有一个 ODE with Time-Dependent Terms
内容如下

Consider the following ODE with time-dependent parameters
y ′ ( t ) + f ( t ) y ( t ) = g ( t ) . y'(t) + f(t)y(t) = g(t). y(t)+f(t)y(t)=g(t).
The initial condition is y 0 = 1 y_0 = 1 y0=1. The function f(t) is defined by the n-by-1 vector f evaluated at times ft. The function g(t) is defined by the m-by-1 vector g evaluated at times gt.

Create the vectors f and g.

ft = linspace(0,5,25);
f = ft.^2 - ft - 3;

gt = linspace(1,6,25);
g = 3*sin(gt-0.25);

Write a function named myode that interpolates f and g to obtain the value of the time-dependent terms at the specified time. Save the function in your current folder to run the rest of the example.
The myode function accepts extra input arguments to evaluate the ODE at each time step, but ode45 only uses the first two input arguments t and y.

function dydt = myode(t,y,ft,f,gt,g)
f = interp1(ft,f,t); % Interpolate the data set (ft,f) at time t
g = interp1(gt,g,t); % Interpolate the data set (gt,g) at time t
dydt = -f.*y + g; % Evaluate ODE at time t

Solve the equation over the time interval [1 5] using ode45. Specify the function using a function handle so that ode45 uses only the first two input arguments of myode. Also, loosen the error thresholds using odeset.

tspan = [1 5];
ic = 1;
opts = odeset('RelTol',1e-2,'AbsTol',1e-4);
[t,y] = ode45(@(t,y) myode(t,y,ft,f,gt,g), tspan, ic, opts);

Plot the solution, |y|, as a function of the time points, |t|.

plot(t,y)

三、如何处理“矩阵”微分方程

在上一节中给出的方法实际上是已经把矩阵微分方程变换成了一列,如果矩阵较大的话还是比较麻烦。
这个帖子给出了较好的解决方案 How can I solve the matrix Riccati differential equation within MATLAB?
或者还可参考
How can I solve a matrix differential equation within MATLAB?
matlab求解时变系统的Riccati矩阵微分方程,matlab,控制,matlab
给出的解决方案如下
The matrix Riccati differential equation:

 dX/dt = A'X + XA - XBB'X + Q

can be solved using the functions in the ODE suite.
Assume your dependent matrix “X” is “n”-by-“n”, and you have known “n”-by-“n” matrices “A”, “B”, and “Q”. The following method will solve the matrix Riccati differential equation. Save the following as a MATLAB file somewhere on the MATLAB Path.

function dXdt = mRiccati(t, X, A, B, Q)
X = reshape(X, size(A)); %Convert from "n^2"-by-1 to "n"-by-"n"
dXdt = A.'*X + X*A - X*B*B.'*X + Q; %Determine derivative
dXdt = dXdt(:); %Convert from "n"-by-"n" to "n^2"-by-1

Then, you can use the ODE45 function to solve this problem:

[T X] = ode45(@(t,X)mRiccati(t, X, A, B, Q), [0 10], X0) 

For example, using the sample data:

A = [1 1; 2 1]; 
B = [1; 1]; 
Q = [2 1; 1 1];
X0 = [1; 1; 1; 1];

You can use the following command to solve the system of differential equation

[T X] = ode45(@(t,X)mRiccati(t, X, A, B, Q), [0 10], X0) 

ODE45 returns “X” as a vector at each time step. You may use the following code to reshape each row of “X” to get the matrix and store it in a cell array:

[m n] = size(X);
XX = mat2cell(X, ones(m,1), n);
fh_reshape = @(x)reshape(x,size(A));
XX = cellfun(fh_reshape,XX,'UniformOutput',false);

The results of this can be verified by the LQR function:

[K,S,E] = lqr(A, B, Q, 1)

where “S” should have results very similar to the last elements in “X” or “XX”. The LQR function computes the steady-state value of the system. In this example, we generated the solution for up to “t = 10”, which is an adequate approximation of infinity for this problem.

For more information on ODE45 and other such solvers, refer to the function reference page for ODE45 in the MATLAB documentation.

对于该方法网上还有人追问,如有需要可查阅

  • https://www.mathworks.com/matlabcentral/answers/225984-how-can-i-solve-matrix-riccati-differential-equation
  • how can i solve matrix riccati differential equation?

四、关于逆向积分

在上面的两个例子中给出的都是初始条件,但实际上Riccati方程给出的往往是终端条件,需要逆向(backward)积分。
对于简单的情况,微分方程中并不含自变量。
此时逆向积分并不复杂,只需要在定义时间区间tspan时把初始时刻和终端时刻调换即可,参考链接为
https://www.mathworks.com/matlabcentral/answers/151336-solving-differential-riccati-equation-with-a-boundary-condition

示例如下

par = [1;2;1];  % q0, q1, and q2
yf = 1;
ti = 0; tf = 2;
opt = odeset('AbsTol',1.0e-07,'RelTol',1.0e-07);
[t,y] = ode45( @riccatiEquation, [tf,ti], yf ,opt, par);

% Visualize
plot(t,y)

function dydx = riccatiEquation(x,y,parameters)
q0 = parameters(1);
q1 = parameters(2);
q2 = parameters(3);

dydx = q0 + q1*y + q2*y*y;
end

或者采用平移的方式,可参考吴受章的最优控制书。
如果实在不行,用变量代换转换成初值问题是不是也行?没有进行仿真验证。

其实对于这类问题有一个更广义的形式,即微分方程的多点边值问题,对此该类问题不能使用ode45解决,而应采用 BVP4CBVP5C 来解决。参考链接如下

  • Using ode45 to solve system of ODEs with some initial conditions and some terminal conditions
  • Solve BVP with Multiple Boundary Conditions
  • https://stackoverflow.com/questions/29162100/how-can-i-solve-a-system-of-odes-with-some-terminal-conditions-in-matlab

五、线性时变系统的Riccati矩阵微分方程

前段时间因事中断了一段时间,现在自己已经不面临这个问题了…
按照前几节的步骤似乎能解决这一问题,但没有经过仿真验证自己心里也不是很有底。

六、补充各类参考链接

时间有限,本来还想给几个例子,看之后自己还有没有机会吧。这里把一些自己在这个过程中的参考链接放上来

How can I solve riccati equation in Simulink with varying state space?

有一些链接给了代码,没来得及细看,但感觉似乎都是时不变系统的文章来源地址https://www.toymoban.com/news/detail-751504.html

  • 这个代码声称解决的是时变矩阵微分方程,但得到的是近似解。而且还有论文支撑,看上去最靠谱 Recursive Approximate Solution to Matrix Diff. Riccati Eq.
  • Solve Riccati Differential Equation (solve_riccati_ode)
  • symmetric differential matrix Riccati equations
  • 这份代码和上一份是同一个人上传到MathWorks网站上的,相差仅一天,可能是一样的 The solve the matrix Riccati differential equation
  • Algebraic Riccati Equation Solver
  • 这份代码也有论文,但似乎很专业,可能是数学专业的 Invariant Galerkin Ansatz Spaces and Davison-Maki Methods for the Numerical Solution of Differential Riccati Equations

到了这里,关于matlab求解时变系统的Riccati矩阵微分方程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • matlab使用教程(27)—微分代数方程(DAE)求解

            微分代数方程是一类微分方程,其中一个或多个因变量导数未出现在方程中。方程中出现的未包含其导数的变量称为代数变量,代数变量的存在意味着您不能将这些方程记为显式形式 y ′ = f t , y 。相反,您可以解算下列形式的 DAE:         • ode15s 和 ode23t

    2024年02月11日
    浏览(32)
  • matlab使用教程(28)—微分方程(ODE)求解常见问题

            本博客说明如何将 ODE 解约束为非负解。施加非负约束不一定总是可有可无,在某些情况下,由于方程的物理解释或解性质的原因,可能有必要施加非负约束。仅在必要时对解施加此约束,例如不这样做积分就会失败或者解将不适用的情况。         如果解的

    2024年02月11日
    浏览(40)
  • MATLAB 之 非线性方程数值求解、最优化问题求解和常微分方程初值问题的数值求解

    非线性方程的求根方法很多,常用的有牛顿迭代法,但该方法需要求原方程的导数,而在实际运算中这一条件有时 是不能满足的,所以又出现了弦截法、二分法等其他方法。 在 MATLAB 中,非线性方程的求解和最优化问题往往需要调用最优化工具箱来解决。优化工具箱提供了一

    2024年02月08日
    浏览(39)
  • 欧拉法与梯形法求解微分方程【含matlab源代码】

    本文介绍两种入门级求解微分方程的方法 —— 梯形法与欧拉法。 将上述方程组改写成matlab语言: 一、欧拉法 1.1 向前欧拉公式 1.2 向后欧拉公式     欧拉法求解源代码       欧拉法结果图   二、梯形法    梯形法求解源代码       梯形法结果图    感谢 Miracle 向公众

    2024年02月15日
    浏览(33)
  • 微分方程+传染病模型(指数传播、SI、SIS、SIR模型)+MATLAB求解

    本文为北海的数模课程学习笔记,课程出自微信公众号:数学建模BOOM。 求赞!求收藏!求关注! 微分方程结合传染病模型(如指数传播、SI、SIS、SIR模型)提供了一种用数学公式描述疾病传播动态的方法,有助于理解和预测疾病在人群中的传播路径和速度。 目录 指数传播模

    2024年02月04日
    浏览(41)
  • PINN深度学习求解微分方程系列一:求解框架

    下面我将介绍内嵌物理知识神经网络(PINN)求解微分方程。首先介绍PINN基本方法,并基于Pytorch框架实现求解一维Poisson方程。 内嵌物理知识神经网络(PINN)入门及相关论文 深度学习求解微分方程系列一:PINN求解框架(Poisson 1d) 深度学习求解微分方程系列二:PINN求解burg

    2023年04月16日
    浏览(27)
  • Fortran 微分方程求解 --ODEPACK

    最近涉及到使用Fortran对微分方程求解,我们知道MATLAB已有内置的函数,比如ode家族,ode15s,对应着不同的求解办法。通过查看odepack的官方文档,我尝试使用了dlsode求解刚性和非刚性常微分方程组。 首先是github网址:https://github.com/jacobwilliams/odepack 具体使用办法: 1.我使用的

    2024年02月11日
    浏览(31)
  • Simulink基础【1】-弹簧-阻尼模型的常微分方程求解

    Simulink是Matlab软件的框图设计环境,可用于各种动态系统的建模、分析与仿真过程。如:导航制导、通讯、电子、机械、热力学等诸多领域。这些系统在数学角度描述上涉及连续、离散、非线性、时变等用解析方法难以求解的系统,因而采用Simulink进行建模与仿真是指导这些系

    2023年04月08日
    浏览(33)
  • Python和Julia TensorFlow科学计算常微分方程求解器

    常微分方程(ODE)可用于描述动态系统。 从某种程度上来说,我们生活在一个动态系统中,窗外的天气从黎明到黄昏都在变化,我们体内发生的新陈代谢也是一个动态系统,因为随着时间的推移,成千上万的反应和分子被合成和降解。 更正式地说,如果我们定义一组变量,

    2024年02月01日
    浏览(26)
  • matlab解微分方程

    f=@(变量) 表达式; x1为2 3 4 5;x2为3 4 5 6的情况下求解函数f的值 用“dsolve” step1: 申明自变量和因变量 syms y(x) step2:编程 得到: step1: 申明自变量和因变量 syms y(x) step2:编程 得到 step1.写函数文件 step2.主函数 相当于定义了一个新向量y,然后列 匿名函数 ,方程的 左边都是一阶

    2024年02月13日
    浏览(36)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包