solving non-linear ODE
Ältere Kommentare anzeigen
I'm trying to solve ODE using MATLAB(ode45), but not working.

In this case, how can I modify code
Here is existing code
a = theta_m / erf(Z)/(2*sqrt(alpha * t));
c = (1 - theta_m)/(erfc(Z)/(2*sqrt(alpha * t)));
term1 = simplify(a - c);
term2 = (sqrt(pi)*rho*del_H/(2*k*(T1-T0))) * exp((Z)^2/(4*alpha^2*t^2));
dZdt = @(t,Z) term1/term2
tspan = [0 5];
Z0 = 0;
[t,Z] = ode45(dZdt, tspan, Z0);
Error using superiorfloat
Inputs must be floats, namely single or double.
Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in untitled3 (line 27)
[t,Z] = ode45(dZdt, tspan, Z0);
Thanks for your support
Akzeptierte Antwort
Weitere Antworten (1)
Steven Lord
am 8 Mai 2024
This line suggests you're performing operations with symbolic variables.
term1 = simplify(a - c);
If so, you're probably going to need to use matlabFunction or odeFunction to create the anonymous function rather than simply dividing your terms (which won't substitute values into the symbolic expression) or use dsolve.
See the section on solving ODEs in the Symbolic Math Toolbox documentation for more information about using dsolve.
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
