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
Best Answer