How to use optimizer with ode45?

조회 수: 2 (최근 30일)
Murad Nazari
Murad Nazari 2018년 2월 26일
댓글: James Tursa 2018년 2월 27일
I have an ordinary differential equation (dT/dt) = (5.4675e-4)q. I have a data set of T vs t where T is temperature and t is time. I want to determine q such that the T calculated from the differential equation will fit the T recorded in the lab. As part of classwork, my professor asked me to use ode45 and optimizer to fit the data to the ODE. I don't know where to start?
Any help will be appreciated.

답변 (2개)

James Tursa
James Tursa 2018년 2월 26일
You would start by writing code to numerically integrate your DE using ode45. You have a simple 1st order ODE. There is an example in the ode45 doc showing how to do a 1st order ODE. Start with that and modify it with your equation using the time span of your data.
Once you have that working, wrap your ode45 stuff inside of a function where you pass in q to the function.
Then ask yourself how you would use an optimizer on this function to minimize the difference between what your function produces for a given q to what your measurements are.
  댓글 수: 2
Murad Nazari
Murad Nazari 2018년 2월 27일
Thanks for the answer. T'=(5.4675e-4)qdt has one extra unknown q. How can I deal with that?
James Tursa
James Tursa 2018년 2월 27일
Just put that as a parameter in your derivative function. E.g.,
q = something;
deriv = @(t,y) (5.4675e-4)*q;
Then pass deriv to ode45 as the 1st argument. Just be sure that every time you change q, you redefine the deriv function handle (otherwise it will continue to use the old q).

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


Star Strider
Star Strider 2018년 2월 26일
If you are fitting your differential equations to data, see Monod kinetics and curve fitting (link), Solving Coupled Differential Equations (link), and Parameter Estimation for a System of Differential Equations (link).
Optimizing differential equations is actually an example in the documentation for the Optimization Toolbox: Optimizing a Simulation or Ordinary Differential Equation (link).

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by