Differential Equation Solver Translation

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

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.
Hey John,
Thanks for taking your time to help with this. I've cleaned up the notation there. I should have been more detailed in my questions to begin with. You are correct that I'm lookin at time and space differentials and was planning to discretize the PDE's using the method of lines and to discretizie the spacial derivative using the finite volume method. I think I'm just getting a bit overwhelmed with solving a system of PDEs for the first time using the software.
Initial Boundary Conditions
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)
qsol = 
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.
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.
Thanks for the advice and your time, have started breaking it down into smaller chunks and have got some traction on it now

Sign in to comment.

Answers (0)

Asked:

CM
on 13 Feb 2021

Commented:

CM
on 13 Feb 2021

Community Treasure Hunt

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

Start Hunting!