## Help solving 3 ODEs

### Kurt (view profile)

on 22 Oct 2018
Latest activity Commented on by Kurt

### Kurt (view profile)

on 22 Oct 2018
Accepted Answer by Stephan

### Stephan (view profile)

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?

R2018b

### Stephan (view profile)

on 22 Oct 2018
Edited by Stephan

### Stephan (view profile)

on 22 Oct 2018

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 - 5/3)*((9*Y)/125 - 9/125))/3
-((Y - 5/3)*((27*Y)/1000 - 9/125))/(3*((3*Y)/8 - 1))
(3*(Y - 1)*(Y - 5/3))/(125*((3*Y)/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

Kurt

### Kurt (view profile)

on 22 Oct 2018
Thanks a lot this helps!