Solve and Optimize ODEs in MATLAB

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 42

  • @welidbenchouche
    @welidbenchouche 5 років тому +2

    for someone watching the programming for engineers playlist, and being new to matlab, it's to hard to follow everything here, still, you are the best professor john, wish you a long happy life, sincerely

  • @franciscopaes6971
    @franciscopaes6971 5 років тому +2

    This video helped me a lot. Thank you for sharing this tutorial with us!

  • @piapsalm7669
    @piapsalm7669 3 роки тому +2

    This videonwill help me a lot in my research. Sir do you have video on ODE sensitivity analysis?

    • @apm
      @apm  3 роки тому

      There are a couple different ways to do the sensitivity analysis. The easiest is to use finite differences with odeint and autograd: kitchingroup.cheme.cmu.edu/blog/2019/09/13/Sensitivity-analysis-with-odeint-and-autograd/ A more exact way is to integrate the ODEs with the adjoint equations to get exact sensitivities.

  • @JessQZ
    @JessQZ 8 років тому +1

    Thanks for your tutorial! It works perfectly!
    I just have a question, can I do the same when I have 3 parameters (and 2 equations) instead of one?

    • @apm
      @apm  8 років тому

      Yes, it should work with any number of parameters (1000's) and variables (10,000+). Additional tutorials on ODE solutions are on the dynamic optimization course at apmonitor.com/do There is also a user's group at apmonitor@googlegroups.com if you need help with your application.

  • @RanjithKumar-vu4og
    @RanjithKumar-vu4og 4 роки тому +1

    I am getting an error like "Unrecognized function or variable 'k0'." when I run it in MATLAB R2019b...
    Can You help me with it,sir?

    • @apm
      @apm  4 роки тому

      When you download the source, make sure you are in the correct run directory before you begin.

  • @tianzhang3120
    @tianzhang3120 7 років тому

    Thank you Prof Hedengren for the great tutorial!!! I have a question with the ODE functions. What if the ODE have time varying external inputs? How can I use my measurement data for those external inputs? For example, dxdt = - k*x + par(t) *x, where par(t) are measured at t = 1, 10, 20, .... Looking forward to your answer! Thanks!

    • @apm
      @apm  7 років тому

      +TIAN ZHANG, use an anonymous function to bring in the additional input. This video: ua-cam.com/video/QKhy1JsdiUo/v-deo.html shares how to do this starting at about 4 minutes. The u value is the additional input. You can put the ode integrator in a loop and have it cycle each time the input changes. You'll need to store the results as you cycle through the loop. Let me know if you need more help.

  • @bayyadibtissam7629
    @bayyadibtissam7629 6 років тому

    Thanks for your tutorial! Can you help me with a problem. how can I call the ode45 output after solving the ODE in ga optimization toolbox as a fitnessfunction

    • @apm
      @apm  6 років тому

      I haven't used the GA optimization toolbox but I encourage you to either try to make the ode45 output a global variable or else see if there are optional arguments that you can pass with the GA optimization output.

  • @Bridging_Roni
    @Bridging_Roni 8 років тому

    Thanks for your tutorial! Can you help me with a problem. I have an equation like dX/dt = AX+BU. X is a 2 dimensional vector. A and B are 2*2. U is known for all the instances. I have to find the optimum A and B for which cost function Y(real) - [0 1]*X is minimum. I want to use fminsearch for the whole thing. I also have initial guess of cost function and the A and B matrices which gave me the initial cost function

    • @apm
      @apm  8 років тому

      Check out #2 at this page: apmonitor.com/che263/index.php/Main/MatlabDynamicSim for integrating a system with more than 1 state. For fmincon, you'll need to create an objective function and call fminsearch (unconstrained) or fmincon (constrained) to find the solution. If you need something that will solve faster than fmincon, then please have a look at APMonitor (Dynamic optimization course at apmonitor.com/do), a MATLAB toolbox.

  • @amnaghoul4502
    @amnaghoul4502 10 років тому

    please i have a system with 2 delays d1 and d2 which are the optimisation’s variable and needs to be find by optimisation tools. Similar to objective function, I have a constrain function (which is again a function of x and has d1 d2 (reals valors) inside).. a help please??

    • @apm
      @apm  10 років тому

      I don't have a specific example for your case. However, there is excellent literature on the subject of time delay estimation. Here is one example: pubs.acs.org/doi/pdf/10.1021/ie300786g

    • @amnaghoul4502
      @amnaghoul4502 10 років тому

      APMonitor.com please sir can you give me the codes m.file because i didn't know how to download it ...and if you have others links i will be very gratiful

    • @apm
      @apm  10 років тому

      Sure, here is the link: apmonitor.com/me575/index.php/Main/DynamicOptimization It is the first zipped archive at the top.

    • @amnaghoul4502
      @amnaghoul4502 10 років тому

      APMonitor.com The page "Main/Dynamicoptimization" doesn't exist :(

  • @meeei85
    @meeei85 8 років тому

    Thank you for this great tutorial. I have one question, if I have the following couple ODE, what is the best way to solve for the unknown parameters?
    dv/dt = (Yv/(m-Xud))*v + (Yr/(m-Xud))*r
    dr/dt = (Nv/(Iz-Nrd))*v + (Nr/(Iz-Nrd))*r + (T/(Iz-Nrd))*Tr
    where the unknown parameters are Yv, Yr, Xud, Nv, Nrd and Nr
    m and Iz are know constants
    dv/dt, dr/dt, v, r and Tr are obtained from experiment.
    Thank you.

    • @apm
      @apm  8 років тому +1

      You can start with the files that are posted to apmonitor.com/me575/index.php/Main/DynamicOptimization or the course on dynamic optimization apmonitor.com/do (see Estimation section). You can create an objective function such as a sum of squared errors to penalize deviation of the model predictions from your measured values.

    • @meeei85
      @meeei85 8 років тому

      Thank you for your answer. I got the idea from your course to solve the problem.

  • @brianmwewa5617
    @brianmwewa5617 10 років тому

    Great stuff here.... i however need some help with regards regression. How can i reach you

    • @apm
      @apm  10 років тому +1

      Brian, I'll be glad to help you with your question on regression. Please subscribe to the e-mail list at apmonitor@googlegroups.com and post a message or contact me directly at john.hedengren@byu.edu.

  • @vineetlundia4404
    @vineetlundia4404 9 років тому

    helo sir
    can you help me out to optimize multiple ode by differential evolution technique??

    • @rrc
      @rrc 9 років тому

      Yes, please see the dynamic optimization course for many tutorials and downloadable example problems at apmonitor.com/do I'll also be glad to help if you'd like to post your problem to the APMonitor user's group.

  • @seanmcolby
    @seanmcolby 10 років тому

    Great lecture and materials! Do you have any example material regarding optimizing multiple parameters in coupled ODE's?
    For example:
    dx(t)/dt = - k1*x(t)
    dy(t)/dt = k1*x(t) - k2*y(t)
    Where a data set for x(t) and y(t) were obtained experimentally, and k1, k2 are unknown. Thanks!

    • @apm
      @apm  10 років тому +1

      Sure, here is one video... ua-cam.com/video/WIXeySSa1fk/v-deo.html

    • @amnaghoul4502
      @amnaghoul4502 10 років тому

      APMonitor.com HI SIR do you have an example about systems with delays witch we search the delays with this..???

    • @jorgelindo_phd
      @jorgelindo_phd 8 років тому

      Hi APMonitor tutor thanks a lot for your videos! I have a question related. Is it possible to run fmincon where my objective matlab function 'myObj' and 'mySim' have multiple parameters (k1, k2 ...)?

    • @apm
      @apm  8 років тому +1

      Yes, you can just add them as input parameters if you use an anonymous function. Here is a similar example but for an ode integration. ua-cam.com/video/QKhy1JsdiUo/v-deo.htmlm32s Same thing applies to passing in parameters to fmincon. Instead of passing in the objective name 'myObj', pass in an anonymous function @(x)myObj(x,p).

    • @jorgelindo_phd
      @jorgelindo_phd 8 років тому

      Thanks a lot!

  • @edisapapracanin4192
    @edisapapracanin4192 9 років тому

    What is myNoise function.....pls help!!!!

    • @apm
      @apm  9 років тому +1

      +edisa avdihodzic myNoise.m is a function that corrupts the data artificially for this example so that we don't have perfect data. The numbers are arbitrary. You will see that myNoise.m function is only used in mySim.m (for simulating) and myObj.m (for computing the objective function). You can download the files at apmonitor.com/me575/index.php/Main/DynamicOptimization

  • @surajkr4-yrb.tech.chemical624
    @surajkr4-yrb.tech.chemical624 7 років тому

    What if I have to optimise just one of the multiple ODEs by varying one or two variables?
    e.g. I have 18 ODEs, each containing the concentration of different reactants and products of an acid hydrolysis reaction. I need to maximize one of the products by varying Temperature and Concentration of acid.

    • @apm
      @apm  7 років тому

      Here is a tutorial on optimizing parameters in an ODE model: ua-cam.com/video/ynm7B0N0_Yw/v-deo.html There is also the dynamic optimization course at apmonitor.com/do

  • @edisapapracanin4192
    @edisapapracanin4192 9 років тому

    Thank very much