I want to use a fixed step method instead of ode45's adaptive time step method. ode4 or ode5 would be suitable (i guess) but i can't use it with system of equations as the way i used with ode45.
clc
clear all
tspan = [0 250];
O0 = [3 0];
[t,O] = ode4(@(t,O) odefcn(t,O), tspan, O0);
subplot(2,1,1);
plot(t,O(:,1),t,O(:,2),'LineWidth',2)
subplot(2,1,2);
x = 0:length(t)-1;
stepsize = diff([0; t]);
plot(t, stepsize)
grid
function dOdt = odefcn(t,O)
dOdt = zeros(2,1);
dOdt(1)=1+sin(O(2)-O(1));
dOdt(2)=1.5+sin(O(1)-O(2));
end
The error message:
Error using ode4
Too many output arguments.
Error in Analysis_Still_Matters_FS (line 6)
[t,O] = ode4(@(t,O) odefcn(t,O), tspan, O0);