Timofey Kargin
Timofey Kargin

Reputation: 181

MatLab ode45 minimal time step

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);

Upvotes: 1

Views: 2579

Answers (2)

ammportal
ammportal

Reputation: 991

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

Upvotes: 0

drhagen
drhagen

Reputation: 9532

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.

Upvotes: 1

Related Questions