Cannot find solution with dsolve but I know that a relatively simple solution does exist
Afficher commentaires plus anciens
I'm using dsolve to solve a simple system of ODE's. I know there must be an analytical solution because our professor has tasked us with finding it, but MATLAB fails to produce a result.
Does anyone know why this would be failing?
Here is my code:
syms a(t) b(t) c(t) d(t) e(t)
ode1 = diff(a,t) == -5*a + .01*e;
ode2 = diff(b,t) == 5*a - 15*b;
ode3 = diff(c,t) == 5*a - .5*c*d;
ode4 = diff(d,t) == 15*b -.5*c*d;
ode5 = diff(e,t) == .5*c*d - .01*e;
odes = [ode1; ode2; ode3; ode4; ode5;];
conds = [a(0) == 5; b(0) == 0; c(0) == 0; d(0) == .5; e(0) == 1];
[a b c d e] = dsolve(odes, conds);
hold on
fplot(a)
fplot(b)
fplot(c)
fplot(d)
fplot(e)
Réponses (1)
Star Strider
le 13 Avr 2021
The dsolve function apparently does not integrate nonlinear differential equations.
This is likely the best you can hope for:
syms a(t) b(t) c(t) d(t) e(t) t Y
ode1 = diff(a,t) == -5*a + .01*e;
ode2 = diff(b,t) == 5*a - 15*b;
ode3 = diff(c,t) == 5*a - .5*c*d;
ode4 = diff(d,t) == 15*b -.5*c*d;
ode5 = diff(e,t) == .5*c*d - .01*e;
odes = [ode1; ode2; ode3; ode4; ode5;];
conds = [a(0) == 5; b(0) == 0; c(0) == 0; d(0) == .5; e(0) == 1];
[VF,Subs] = odeToVectorField(odes);
odes_fcn = matlabFunction(VF, 'Vars',{t,Y});
tspan = [0 10];
ics = [0 5 0 0.5 1];
[t,y] = ode45(odes_fcn, tspan, ics);
figure
plot(t,y)
grid
legend(string(Subs), 'Location','best')
.
Catégories
En savoir plus sur Numeric Solvers dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!