How do I force ode45 to take steps of exactly 0.01 on the T axis?

前端 未结 6 1912
再見小時候
再見小時候 2021-01-05 14:44

I\'m using Matlab to solve a differential equation. I want to force ode45 to take constant steps, so it always increments 0.01 on the T axis while solving the equation. How

6条回答
  •  孤独总比滥情好
    2021-01-05 15:20

    ODE45 (speak four-five not fortyfive) calculates the optimal stepsize and even goes back in time if the error is to large, check Runge-Kutta if you are interested. As a user you don't notice this since the output of ODE will be interpolated such that is suits the tspan vector. So if you set tspan to 0:1E-5:1 and you want to integrate a easy ODE such as dydt=-y ODE45 will make a few steps but the vektor you get out of the ode will be in time steps declared in tspan i.e. 1E-5. If you want to integrate the stiff equation dydt=1E2*(1-y)*y ODE45 will make large and very tiny steps but the output will be the same, for the later you should use ode15s because ODE45 can't handle stiff systems.

    Hope this helps

    cheers Marco

提交回复
热议问题