How can i prove Runge-Kutta method depends on time steps?
3 次查看(过去 30 天)
显示 更早的评论
Ode45 in matlab uses adaptive time steps. My assignment is to prove that the error from solution obtained by Runge-Kutta method depends on the time stepping. I tried to use ode45 in a loop to calculate the value of the vector 'm' at each time step, but i've no control on the number of steps used by the ode45, even though i'm sending only two time values.
Is there any way that i could use ode45 to obtain a solution dependent on the time steps explicitly mentioned in the code, perhaps by making ode45 to take fixed time steps instead of adaptive? Or if there is no other way to solve this problem other than writing my own Runge-Kutta function with fixed time steps? I've attached the code as follows:
time = linspace(0,tmax,tcount)
for RK=1:length(time)-1
t = [time(RK) time(RK+1)];
[t1,m1] = ode45(@(t1,y1)myfun(t1,y1, s), t, m); % s is a structure of constant values
disp(length(m1))
RK_m(RK,:)=m1';
end
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 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!