Solving Coupled Differential Equations

8 Ansichten (letzte 30 Tage)
Dave Black
Dave Black am 15 Mär. 2017
Kommentiert: Rik am 17 Mär. 2023
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 Kommentare
Shyamal Laxman Hanabar-
Shyamal Laxman Hanabar- am 17 Mär. 2023
Verschoben: Rik am 17 Mär. 2023
Write matlab code for find du/dz if u=loge(x^3+y^3+z^3-3*x*y*z^3)
Rik
Rik am 17 Mär. 2023
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 15 Mär. 2017
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 Kommentare
Dave Black
Dave Black am 6 Apr. 2017
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 am 6 Apr. 2017
My pleasure.
Using this optimised parameter estimation, your results are the correct results!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Roger Stafford
Roger Stafford am 16 Mär. 2017
Bearbeitet: Roger Stafford am 16 Mär. 2017
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