How do I solve coupled ordinary differential equations with boundary conditions?

3 ビュー (過去 30 日間)
kyana shayan
kyana shayan 2015 年 8 月 10 日
コメント済み: kyana shayan 2015 年 8 月 16 日
I have four coupled ODE's. I am not sure how to plot and solve them using Matlab. The equations are: dy(1)=y(2); dy(2)=10*((50000*y(1)*exp(-10/y(3)))+y(2)); dy(3)=y(4); dy(4)=10*((-100000*y(1)*exp(-10/y(3)))+y(4)); with following boundary conditions: y1(0) = 1, y3(0) = 0, y2(2) = 0, y4(2) = 0 I think they can be solved numerically, but I'm not sure how. can anyone help me with my problem? tnx

回答 (1 件)

Torsten
Torsten 2015 年 8 月 10 日
編集済み: Torsten 2015 年 8 月 11 日
function mat4bvp
solinit = bvpinit(linspace(0,2,10),[1 0 1e-5 0]);
sol = bvp4c(@mat4ode,@mat4bc,solinit);
x = linspace(0,2);
y = deval(sol,x);
plot(x,y(1,:),x,y(2,:),x,y(3,:),x,y(4,:))
% ------------------------------------------------------------
function dydx = mat4ode(x,y)
dydx = [ y(2)
10*(50000*y(1)*exp(-10/y(3))+y(2))
y(4)
10*(-100000*y(1)*exp(-10/y(3))+y(4)) ];
% ------------------------------------------------------------
function res = mat4bc(ya,yb)
res = [ ya(1)-1
yb(2)
ya(3)
yb(4) ];
% ------------------------------------------------------------
Best wishes
Torsten.
  1 件のコメント
kyana shayan
kyana shayan 2015 年 8 月 16 日
thank you for your time Torsten, but I don't get it. should I open 3 scripts, and put the functions in each? can you tell me how this code works?

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by