Effacer les filtres
Effacer les filtres

How can I solve This system of ODEs?

2 vues (au cours des 30 derniers jours)
Jaser Adosari
Jaser Adosari le 1 Déc 2017
I tried to solve these ODE equations but there is an error!
This is my code:
syms x1(w) x2(w) x3(w)
T=773.15; R=1.314;
[x1Sol(w), x2Sol(w), x3Sol(w)] = dsolve(odes,conds)
And this is the error message
Warning: Explicit solution could not be found.
> In dsolve (line 201)
Error using sym/subsindex (line 796)
Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and
the body of the function is a SYM expression. When indexing, the input must be numeric, logical, or ':'.

Réponses (2)

Star Strider
Star Strider le 1 Déc 2017
You can create a function usable in the numeric ODE solvers by adding:
[odes_vf, vfsubs] = odeToVectorField(odes);
odes_fcn = matlabFunction(odes_vf, 'Vars',{w, Y});
[w,y] = ode15s(odes_fcn, [0 1], [2; 0; 4]);
just after your ‘odes’ assignment. However when I tried that, the numerical integration threw warnings and produced nothing.

Karan Gill
Karan Gill le 1 Déc 2017
You have numeric values in your equations, so solve this numerically. Try ode45: https://www.mathworks.com/help/matlab/ref/ode45.html
For the difference between symbolic and numeric methods, see: https://www.mathworks.com/help/symbolic/choose-symbolic-or-numeric-arithmetic.html.
The error is because you didn't declare the symbolic functions [x1Sol(w), x2Sol(w), x3Sol(w)]. You can ignore it for the moment and focus on getting a solution.


Community Treasure Hunt

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

Start Hunting!

Translated by