1
votes

I'm trying to solve differential equations with MatLab and ode45 function. The question is how can I change minimal step size? I want to make it bigger to avoid too small steps. I'm tryin to do it like this:

tspan = [3, 4]; (boundaries of time line)
[t, q] = ode45('dqdt2', tspan, q0);
  • t - time
  • q - solution to find
  • dqdt2 - my file with function
  • q0 - initial conditions
2
Not quite what you're looking for, but in addition to the suggestion by @drhagen to change tolerances, for ode45 you can set the Refine parameter to 1 (defaults to 4 in ode45) - dkv

2 Answers

1
votes

You can't.

In Matlab, variable step size solvers cannot be given a minimum step size, probably because it doesn't make all that much sense to do so. If you wish to reduce the accuracy of your solution in order to speed up the solution, increase RelTol and AbsTol. With increased tolerance, the solver will generally take larger steps but there will still be no specific minimum step size.

0
votes

There is a way to set the step size for ode45 and other step solvers. When you are defining TSPAN you can specify a set of values that you want the solution for. This will not affect the internal steps taken by the solver but will help the solver in efficient memory management. You can look at the documentation here (Thanks to edwinksl for pointing it out).

%Your Code
tspan = [3, 4]; %MATLAB here uses the in built step size

%Set Step size. Say you want a step size of 0.1
tspan = 3:0.1:4;
%This will run over only those values of t that are defined by tspan