MATLAB: Is ODE45 using so many intervals

odeode45

Hi all,
I'm using the code below to solve an ODE. It's not problematic per se, but I'm just wondering if there is a way to force it to use less intervals? As it is written below, I get 22,237 entries for both x and y in my sol structure.
options=odeset('RelTol', 1e-8, 'AbsTol', 1e-8);
tspan=[0 50];
ODE = @(t,x,gamma,psi,beta) [-gamma*x(1) + psi*x(1); beta*x(2) - x(1)*x(2)];
sol = ode45(@(t,x) ODE(t,x,0.4116,0.6026,0.7505), tspan, [1 29], options);

Best Answer

It will use as many intervals as it needs to.
If you want it to output fewer intervals, create ‘tspan’ as a vector of more than two elements, for example:
tspan = linspace(0, 50, 25);
will result in the result having 25 values for the time vector and a (25xN) matrix for the integrated solution.