Help solving 3 ODEs

1 次查看(过去 30 天)
Kurt
Kurt 2018-10-22
评论: Kurt 2018-10-22

I'm trying to solve these 3 ODEs with ODE45.

d(xA)/d(v)=(0.2*(0.6^2)*((1-(0.375*xA)))*(((5/3)-xA)/(1-0.375*xA))))/(3);
d(xB)/d(v)=(0.2*(0.6^2)*((1-xB)/(1-(0*xB)))*(((5/3)-xB)/(1-0*xB)))/(3);
d(xC)/d(v)=(0.2*(0.6^2)*((1-xC)/(1-(0.75*xC)))*(((5/3)-xC)/(1-0.75*xC)))/(3);
v(f)=47
v(0)=0
xA(0)=0
xB(0)=0
xC(0)=0

What do I do?

采纳的回答

Stephan
Stephan 2018-10-22
编辑:Stephan 2018-10-22
Hi,
try this:
syms xA(v) xB(v) xC(v)
eqn1 = diff(xA, v) == (0.2*(0.6^2)*((1-(0.375*xA)))*(((5/3)-xA)/(1-0.375*xA)))/(3);
eqn2 = diff(xB, v) == (0.2*(0.6^2)*((1-xB)/(1-(0*xB)))*(((5/3)-xB)/(1-0*xB)))/(3);
eqn3 = diff(xC, v) == (0.2*(0.6^2)*((1-xC)/(1-(0.75*xC)))*(((5/3)-xC)/(1-0.75*xC)))/(3);
[odes, vars] = odeToVectorField(eqn1, eqn2, eqn3);
fun = matlabFunction(odes,'Vars',{'t','Y'});
x0 = [0 0 0];
tspan = [0 47];
[t, sol] = ode45(fun,tspan,x0);
xA = sol(:,2);
xB = sol(:,1);
xC = sol(:,3);
plot(t,xA,t,xB,t,xC)
legend('xA','xB','xC','Location','southeast')
Note that for some reasons Matlab changes the order of the variables, so that xA = Y(2) and xB = Y(1):
odes =
((Y[1] - 5/3)*((9*Y[1])/125 - 9/125))/3
-((Y[2] - 5/3)*((27*Y[2])/1000 - 9/125))/(3*((3*Y[2])/8 - 1))
(3*(Y[3] - 1)*(Y[3] - 5/3))/(125*((3*Y[3])/4 - 1)^2)
vars =
xB
xA
xC
- dont ask me why this happens, but you have to take it into account. The result is:
.
Best regards
Stephan

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by