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!