How to solve this differential equation?
Afficher commentaires plus anciens

I´m looking for dC/dx and C(x)
Parameters n, D, F, R, T, I, K are independet to x
How can I apply the one of the ode solvers to this problem with a given intial condition?
Thanks!
1 commentaire
RahulTandon
le 6 Juil 2015
the best i cud do is below!!
Réponses (2)
Star Strider
le 4 Juil 2015
I may be missing something (if so I’ll defer to those with greater expertise if I am), the Symbolic Math Toolbox can do this easily. (You could probably do it almost as easily by hand, but then this is MATLAB Answers.)
It seems your first equation can be integrated to be a simple first-order differential equation, and although you use the partial derivative notation, both are actually ordinary differential equations. You could then substitute directly for diff(theta) in the first.
Using the Symbolic Math Toolbox, this is the code and result:
syms C(x) n D F R T I K Th(x) C0 Th0
Eq1 = diff(C,2) == diff(-n*D*(C)*F/(R*T)*diff(Th)); % First Eqn, Integrated w.r.t. ‘x’
Eq2 = diff(Th) == -R*T/(F*K*C) * ((1/F) + K*diff(C)); % Second Eqn
Eq3 = diff(C) == -n*D*(C)*F/(R*T)*(-R*T/(F*K*C) * ((1/F) + K*diff(C))); % Substitute Manually
C(x) = dsolve(Eq3, C(0) == C0)
C(x) =
C0 + (D*n*x)/(F*K - D*F*K*n)
Where C0=C(0).
Solving for Th(x):
Eq4 = diff(Th) == -R*T/(F*K*C(x)) * (1/F);
Th(x) = dsolve(Eq4, Th(0) == Th0)
Th(x) =
Th0 - (log(C0*F*K + D*n*x - C0*D*F*K*n)*(R*T - D*R*T*n))/(D*F*n) + (log(C0*F*K - C0*D*F*K*n)*(R*T - D*R*T*n))/(D*F*n)
Where Th0=Th(0).
You could easily create anonymous functions from these, or use matlabFunction to do it.
Note: I used R2015a to do this, but earlier versions should work.
RahulTandon
le 6 Juil 2015
0 votes
syms x C theta n Dee F R T I K clear; clc; str1 = '-Dee*Dy - n*Dee*C*F/(R*T)*D2theta == 0'; %wrt x str2 = 'Dtheta+R*T/F(1/(K*C)*(1/F + K*y)) == 0 '; str3 = 'y == DC'; y = dsolve(str1,str2,str3,'x')
Catégories
En savoir plus sur Ordinary Differential Equations 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!