Solve ode system numerically

1 view (last 30 days)
Zhaokai Yin
Zhaokai Yin on 29 Oct 2021
Edited: William Rose on 3 Nov 2021
Hello, I'm trying to repeat one of model in a scientifc paper. Is there are any method using ode45 to solve following eqns same time.
Thank you so much.
Zhaokai Yin
Zhaokai Yin on 29 Oct 2021
Thanks for replying. Dplus,Dminus and A all are scalar constants.

Sign in to comment.

Answers (2)

John D'Errico
John D'Errico on 3 Nov 2021
Edited: John D'Errico on 3 Nov 2021
Not that hard. As @William Rose sugggests, the mass matrix solves it, but you need to look carefully at the problem.
J is given as a function of the other derivatives. But J appears only in the other equations in a simple form. So, substitute into equations 1 and 2 for J. Now, move all the derivative terms to the left hand side. Collect terms. I won't do the work for you, because the notation is nasty to write. (The symbolic TB should help in this if you want, but it is just basic algebra.) And anyway, you don't give the constants, so I cannot show the solution as an example.
In the end, you will have a mass matrix for a TWO equation system, in TWO variables, C and phi. So the mass matrix will be 2x2, a function of the variables, but that is not a problem. You have two initial values at x==0, so ODE45 should have no problem, unless there is a singularity in the mass matrix. I'd worry about that when there is a reason to worry. A singularity should arise only if A == 2*C(x), so you might watch for that case. Regardless, that was going to kill you in any event.
Once you have solved for C(x) and phi(x), then you can recover J(x).
As I said, not difficult.

William Rose
William Rose on 2 Nov 2021
This is a good question. I thought it could be done with ode45, by using the mass matrix option. This appears to be exactly the kind of problem the mass matrix option is supposed to solve. See the online help here: Choosing an ODE solver, and here: solve baton ODEs. But see the issue below.
The attached code demonstrates the use of the mass matrix for this problem.
The code runs, but the results are mostly NaNs, because the mass matrix is not invertible. It is not invertible because of the structure of the problem.
M = [1 0 0
0 1 0
-Dp -Dp*C 0]
The mass matrix above is obviously singular.
I suspect there is a way to do this with ode45() which should be obvious - but I don't see it.
William Rose
William Rose on 3 Nov 2021
The equations in the figure can be simplified to a pair of linear equations for and for . I was encouraged when I realized this, because I thought I would solve the system of equations to obtain a solution that could be used in ode45(). However, the right hand side of the system is zero, so the only solution is when ==J=0, for all values of x. This is not very interesting. See attached. Check my work, in case I made a mistake.
Other questions and notes:
  • Please provide the citation for the scientific paper which was the source of the equations.
  • What are the initial values for C and φ and J?
  • I assume the asterisk in the equation for represents simple multiplication.
  • The equation for can be simplified by eliminating from the numerator and denominator.

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!