Differential Equation Solver Translation
Show older comments
Hey,
I'm new to matlab and am struggling to translate the below equation into matlab. Would someone be able to point me to a useful example to work off or demonstrate how this should be executed in matlab?



Any help would be much appreciated.
5 Comments
John D'Errico
on 13 Feb 2021
Difficult to read your non-standard notation. But it appears this is a PDE, not an ODE. You have time differentials on three variables, thus c, cp, and q. But you also have what appears to be a spatial differential on c.
As well, you do not tell what are the boundary conditions. That would likely help to direct the solution method. You may choose to consider a method of lines of sorts. Or you could set this up directly as a large linear system of equations where you discretize it all using finite differences, and then solve as a large linear system, since it appears that everything does enter linearly.
CM
on 13 Feb 2021
I'm still a little confused.
q is independent of the others. It depends only on constants g and h. Also, you do not provide initial conditions on q. But suppose you have some initial value of q as q0=q(0).
syms q(t) g h q0
qsol = dsolve(diff(q,t) == g*(h - q(t)),q(0) == q0)
So there is no need to worry about q. You already effectively know that relation. And while you have a dq/dt term in there, you can substitute it as g*(h-q(t)) into the other equations, before you ever bother to solve them.
As for the rest, it looks like this problem can be solved using pdepe.
You could surely use the PDE toolbox? This seems a pretty simple case. As well, it looks like the chebfun toolbox also provides a pde solver. You can download chebfun from the file exchange.
Sorry, but I don't have much expertise on PDE solvers. But I would start by a very careful reading of the docs for pdepe, where it seems to show a similar problem as the first example.
Bjorn Gustavsson
on 13 Feb 2021
Then one advice is to take hte problem in steps. First you focus on solving one of the PDEs - that way you can separate the difficulties into smaller pieces. If you go for MOL then I suggest you first get familiar with the ode-integrating functions in matlab, i.e. ode45 and its siblings.
CM
on 13 Feb 2021
Answers (0)
Categories
Find more on General PDEs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
