solution to 2nd order ode having time varying coefficients using RK4 steps in Matlab
4 次查看(过去 30 天)
显示 更早的评论
Hello everybody, I am trying to solve a 2nd order ODE using RK4. The coefficients are time dependent and assume new values after a fixed time interval and needs to be updated from the solution to previous steps. I think I have to use a loop. Can I connect this to any standard suite like ode45? Or do I need to write down the RK4 algorithm in steps and then use a loop counter?
Note: The fixed time interval can be same as the stepped time interval we use while solving the ode suite.
Generally any IVP evolves with time for a given set of coefficients. In this case if the coefficients themselves were to change every second will I be able to capture the transient dynamics or I need to go for a time step one order lower with the ode suite to capture the dynamics? Then how do I run a loop along with the suite like ode45?
Thank you.
2 个评论
James Tursa
2020-4-16
Please tell us more about the time varying nature of the coefficients. Are they step functions? Do they happen based on some event? Are they functions of the state vector? Etc.
Can you provide an example of how they change?
回答(1 个)
Ameer Hamza
2020-4-15
编辑:Ameer Hamza
2020-4-15
ode45 is capable of handling time-varying parameters. See this example for details: https://www.mathworks.com/help/matlab/ref/ode45.html#bu3l43b
You don't need to write a loop yourself. Just modify the parameter inside the ODE function according to your requirement.
3 个评论
Ameer Hamza
2020-4-16
Can you clarify what do you mean by "time varying coefficients updated based on previous solution steps"? Can you give an example of the ODE system?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!