How can i prove Runge-Kutta method depends on time steps?

2 ビュー (過去 30 日間)
mangolika bhattacharya
mangolika bhattacharya 2016 年 12 月 12 日
編集済み: José-Luis 2016 年 12 月 13 日
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

採用された回答

José-Luis
José-Luis 2016 年 12 月 12 日
編集済み: José-Luis 2016 年 12 月 13 日
No, a variable-step size is always used for ode45 as per the documentation.
The Mathworks support team has provided code for ode4 (see this link) that can use a fixed step size and looks suitable for your problem.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by