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

조회 수: 22(최근 30일)
kyana shayan 10 Aug 2015
댓글: kyana shayan 16 Aug 2015
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 10 Aug 2015
편집: Torsten 11 Aug 2015
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 16 Aug 2015
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?

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by