Hello! I want to solve a system of Differential equations involving matrix of Unknowns. Can I use ode45?

2 次查看(过去 30 天)
Solve the following system of ODE's
\[
d/dt Y(t)=-(H(t))^{T}Y(t)
d/dt V(t)=-Y(t)^{T}Q^{T}QY(t)
\]
with the terminal conditions Y(T)=I_{2} and V(T)=0. Y, V, H and Q are 2*2 matrices.
In fact
\[
H(t)=H-Q^{T}Q\psi\left(T-t, R+M\right)
\]
where
$\psi\left(T-t, R+M\right)$
and
$\phi\left(T-t, R+M\right)$
solve the following system of ODE's for
$\tau=T-t$
\
[
\frac{d\phi}{d\tau}=Tr[\beta Q^{T}Q\psi\left(\tau, R+M\right)]
\]
\[
\frac{d\psi}{d\tau}=\psi\left(\tau, R+M\right)H+H^{T}\psi\left(\tau, R+M\right)-2\psi\left(\tau, R+M\right)Q^{T}Q\psi\left(\tau, R+M\right)+R+M
\]
with the INITIAL conditions $\phi\left(0, R+M\right)=0$ and $\psi\left(0, R+M\right)=0$. $\psi\left(\tau, R+M\right)$ is a $2*2$ matrix and $\phi\left(\tau, R+M\right)$ is a scalar. The $T$ in the superscript is transpose.
\section{Numerical Experiments}
For all experiments below
$T =15$; $\beta=3$
\[
R=
\begin{bmatrix}
1 & 0 \\
0 & 0
\end{bmatrix}
\]
\[
M=
\begin{bmatrix}
0 & 0 \\
0 & 1
\end{bmatrix}
\]
\[
H=
\begin{bmatrix}
-0.5 & 0.4 \\
0.007 & -0.008
\end{bmatrix}
\]
\[
Q=
\begin{bmatrix}
0.06 & -0.0006 \\
-0.06 & 0.006
\end{bmatrix}
\]
  1 个评论
RB
RB 2017-3-19
编辑:RB 2017-3-20
Dear Carl,
Thanks for replying. Apologies for the editing. I have the terminal values but the equation is involving 2*2 matrices.
Solve the following system of ODE's
d/dt Y(t)=-(H(t))^{'}Y(t)
d/dt V(t)=-Y(t)^{'}Q^{'}QY(t)
with the terminal conditions Y(T)=I_{2} and V(T)=0. Y, V, H and Q are 2*2 matrices and ' stands for transpose.
Also
H(t)=H-Q^{'}Q*W(T-t)
where W(T-t)=W(tau) is determined by the matrix Ricatti equation
dW/dtau = W(tau)H+H^{'}W(tau)-2W(tau)Q^{'}QW(tau)+I_{2}
such that at tau=0
W(0)=0.
I am badly stuck up.
I am unable to use ode45 since I want matrix result.
It would be great if you can give a suggestion.
\[
H=
\begin{bmatrix}
-0.5 & 0.4 \\
0.007 & -0.008
\end{bmatrix}
\]
\[
Q=
\begin{bmatrix}
0.06 & -0.0006 \\
-0.06 & 0.006
\end{bmatrix}
\]
Thanks.
Actually I am solving a system of matrix odes where dx/dt, dy/dt, dz/dt are all 2 by 2 matrices and I need to get X,Y,Z which are again 2 by 2 matrices. My code is
function [dXdt, dYdt, dVdt] = mwish7(t, X, Y, V, A, B, R) X = reshape(X, size(A)); Y = reshape(Y, size(A)); V = reshape(V, size(A)); dXdt = -A.'*X - X*A + 2*X*(B.'*B)*X - R; dYdt = -(A-(B.'*B)*X).'*Y; dVdt = -Y.'*(B.'*B)*Y; dXdt = dXdt(:); dYdt = dYdt(:); dVdt = dVdt(:); end
and the ode45 program I use is
A=[-0.5, 0.4; 0.007, -0.008]; B=[0.06 -0.0006; -0.06, 0.006]; R = [1 0; 0 1]; X0 = [0, 0; 0, 0]; Y0 = [1 0; 0 1]; V0 = [0, 0; 0, 0]; [T X Y V] = ode45(@(t,X,Y,V)mwish7(t, X, Y, V, A, B, R), [15 0], X0, Y0, V0)
I get the error: NOT ENOUGH INPUT ARGUMENTS.
Regards, RB

请先登录,再进行评论。

回答(1 个)

Carl
Carl 2017-2-8
编辑:Carl 2017-2-8
I'm unable to understand much of your question, due to the formatting. However, MATLAB, and ode45 specifically, can be used to solve a system of ODEs. See the following page, under the "Systems of ODEs" heading:
And the following section in the documentation for ode45:
Basically, you can structure the odefun input function to encode the system of equations you would like to solve for.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by