Borrar filtros
Borrar filtros

How to use optimizer with ode45?

7 visualizaciones (últimos 30 días)
Murad Nazari
Murad Nazari el 26 de Feb. de 2018
Comentada: James Tursa el 27 de Feb. de 2018
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.

Respuestas (2)

James Tursa
James Tursa el 26 de Feb. de 2018
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 comentarios
Murad Nazari
Murad Nazari el 27 de Feb. de 2018
Thanks for the answer. T'=(5.4675e-4)qdt has one extra unknown q. How can I deal with that?
James Tursa
James Tursa el 27 de Feb. de 2018
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).

Iniciar sesión para comentar.


Star Strider
Star Strider el 26 de Feb. de 2018
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).

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by