Solving Coupled Differential Equations

조회 수: 8 (최근 30일)
Dave Black
Dave Black 2017년 3월 15일
댓글: Rik 2023년 3월 17일
For my problem I have two differential equations. These are:
dx/dt = -xp + yq + (1-x-y)q
dy/dt = -yq + (1-x-y)u
For my problem I have a given set of historical data and my objective is to find the best values for p,q & u to give the best fit to this historical data. I have a column of historical data related to each equation above. I also need to find the best initial conditions for each equation.
So far I have attempted to use For loops for each of p,q&u in order to find the best values compared with my data.
My problem is that I am not too sure on how to code this correctly. If anybody could help me make a start that would be great. I understand the general idea but am unsure of how to carry this out in Matlab
  댓글 수: 3
Shyamal Laxman Hanabar-
Shyamal Laxman Hanabar- 2023년 3월 17일
이동: Rik 2023년 3월 17일
Write matlab code for find du/dz if u=loge(x^3+y^3+z^3-3*x*y*z^3)
Rik
Rik 2023년 3월 17일
I moved your (@Shyamal Laxman Hanabar-) comments to the question, since they are not answers. You have already received advice on your separately posted question.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2017년 3월 15일
If you are fitting a system of differential equations to data, see Monod kinetics and curve fitting. It uses estimated parameters to define the initial conditions as well as fit the data. It should be straightforward to adapt it to your problem.
  댓글 수: 28
Dave Black
Dave Black 2017년 4월 6일
It's just odd isn't it. Yes, I switched so they match and now the results do indeed make sense. Also when I extrapolate the graphs out the analysis results I am looking for (e.g. the year when x<0.1) match perfectly those of my adviser. So I think this is it working and I thank you so much for this
Star Strider
Star Strider 2017년 4월 6일
My pleasure.
Using this optimised parameter estimation, your results are the correct results!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Roger Stafford
Roger Stafford 2017년 3월 16일
편집: Roger Stafford 2017년 3월 16일
I would think it would be far more efficient to do your fitting using a general solution to your two linear differential equations. That way you could use some of the fitting tools that matlab has. Happily, according to dsolve (after a little simplification) the general solution involves just exponential functions and is:
x = C1*(p-u)/u*exp(-(p+q)*t) + q/(p+q);
y = C1*exp(-(p+q)*t) + C2*exp(-(u+q)*t) + p*u/((u+q)*(p+q));
where p, q, and u are the given parameters and C1 and C2 are dependent on initial values of x and y. This means you have a straight-forward five-dimensional fitting problem to solve, rather than having to deal with differential equations.
Note: Are you sure about the first differential equation
dx/dt = -x*p + y*q + (1-x-y)*q ?
Notice that the y terms cancel each other, giving the simpler
dx/dt = -(p+q)*x + q
expression which does not involve y.

Community Treasure Hunt

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

Start Hunting!

Translated by