Non linear differential equations system

3 views (last 30 days)
thanos tria
thanos tria on 26 Mar 2019
Commented: Walter Roberson on 26 Mar 2019
Hello, i am trying to solve a non linear system but when i plot the solutions only a straight line in one of the variables appears on the graph, and all the variables just can't get away from the initial conditions. That's my code:
syms c1(t) c2(t) c3(t) c4(t) T Y
Eqns = [diff(c1(t),t) == -0.015*c1+1.8*10^(-14)*c2*c4;
diff(c2(t),t) == 0.015*c1-1.8*10^(-14)*c2*c4;
diff(c3(t),t) == -6*10^(-34)*c3*0.051765*10^(20)*0.2465*10^(20)+0.015*c1;
diff(c4(t),t) == 6*10^(-34)*c3*0.051765*10^(20)*0.2465*10^(20)-1.8*10^(-14)*c2*c4];
>> [DEsys,Subs] = odeToVectorField(Eqns);
>> DEFcn = matlabFunction(DEsys, 'Vars',{T,Y});
>> tspan = [0,50000];
>> y0 = [0.040923*10^(12) 0 0 0];
>> [T,Y] = ode45(DEFcn, tspan, y0);
>> plot(T,Y)
And that's my graph:
It sould have had some curves because it describes how ozon is formulated in the atmosphere. Any suggestions??
  3 Comments
thanos tria
thanos tria on 26 Mar 2019
i tried ode23s and ode15s and still straight line
Walter Roberson
Walter Roberson on 26 Mar 2019
You could consider using the MuPAD numeric ode routines; https://www.mathworks.com/help/symbolic/mupad_ref/numeric-odesolve.html
These are inside the Symbolic engine. As of R2019a it is still possible to invoke mupad to get an interactive MuPAD session, but it is not clear how much longer that will be available.
To use those routines without an interactive MuPAD interface, then you need to use
evalin(symengine, 'MUPAD CODE')
or
feval(symengine, 'MUPAD_FUNCTION_NAME', argument1, argument2, ...)
Generally speaking, not all Mupad arguments can be be constructed at all easily at the MATLAB level. In places that the MuPAD documentation shows arrays with [] then sometimes feval() with a MATLAB vector or array is fine, but other times getting the right argument type to make MuPAD happy can be a nuisance.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!