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

3 views (last 30 days)
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

Answers (1)

Torsten
Torsten on 10 Aug 2015
Edited: Torsten on 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 Comment
kyana shayan
kyana shayan on 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?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!