Simultaneously numerically integrate multiple ODE's in MATLAB

2 ビュー (過去 30 日間)
Rong Song
Rong Song 2019 年 10 月 5 日
回答済み: Pavel Osipov 2019 年 10 月 6 日
I was trying to solve a system of muptiple ODEODE at the same time in Matlab but wasn't sure how should I solve for that.
So if I have
dy1/dx=sum of yi , i from 1 to j
dy2/dx=y1^2-y2*sum of yi, i from 1 to j
dy3/dx=y1*y2+y2^2- y3*sum of yi, i from 1 to j
and given initial condition that y1(0)=1 other yi=0 (i>1)
Could anyone have me with this please? Thank you!
  2 件のコメント
darova
darova 2019 年 10 月 5 日
Show your attempts
Rong Song
Rong Song 2019 年 10 月 5 日
K=10;
% Initial Conditio
for k=1:K
if k==1
yi(k)=1;
else
yi(k)=0;
end
end
b=0;
d=20;
% y include y1 y2 y3 y4...to yK
y=zeros(1,100);
for k=1:K
if k==1
y=e(k);
dydd{k}=@(y,t) -y(k)*sum(y);
else
y=e(k);
for j=1:k-1
b=b+y(j)*y(k-j);
end
dydd{k}=@(y,t) 1/(2*y(k))*b-y(k)*sum(y);
end
end
interval=linspace(0,d,100);
[t,y]=ode45(dydd,interval,yi);

サインインしてコメントする。

回答 (2 件)

Pavel Osipov
Pavel Osipov 2019 年 10 月 5 日
"I was trying to solve a system of multiple orders at the same time in Matlab but wasn't sure how should I solve for that". "is that right?"
Then imagine the left part as a system of equations of the 1st order and solve in Matlab in vector form. Good luck!
  1 件のコメント
Rong Song
Rong Song 2019 年 10 月 5 日
Do you mean treat the y1 y2... yi as a vector ? But ode45 doesn't allow me to integrate a vector.

サインインしてコメントする。


Pavel Osipov
Pavel Osipov 2019 年 10 月 6 日
ode45.PNG
odefun.PNG

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by