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

2 Ansichten (letzte 30 Tage)
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

Antworten (1)

Torsten
Torsten am 10 Aug. 2015
Bearbeitet: Torsten am 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 Kommentar
kyana shayan
kyana shayan am 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?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by