0

What is the relationship between number of datapoints and the time step and integration step? How to determine the step size so that I can generate N number of points?

For example, when N=1000 datapoints (length of each of the time series) what should be t and the integration time step, dt. Again, if I want to generate N=10k then how to determine t and dt. The code below is for simulating the Rossler system. I am getting a funny plot instead of the usual attractor. I want to generate a user defined N number of points. But I cannot understand what values should t and dt should be taken. Rossler system should give a neat chaotic attractor at the parameter values of a=0.38,b=0.2,c=5.7.

a = 0.38; b = 0.2; c = 5.7;
t = [0,50];
xinit = [-20 0 0];
ross = @(t, x) [-x(2)-x(3); x(1) + a*x(2); b + x(3)*(x(1) - c)];
[T, X] = ode45(ross, t, xinit);
figure; hold on;
plot3(X(:,1), X(:,2), X(:,3))
Sm1
  • 560
  • 2
  • 6
  • 24

1 Answers1

0

For example, when N=1000 datapoints (length of each of the time series) what should be t and the integration time step, dt

t should be your 1-by-N 'datapoints'. With ode45, it allows you to do initial and end points only.

dt is the durations between neighbouring time points. You don't need it for ode45. If you need to know what Matlab does, check this article or pick up the first book in their reference list.

how to determine t

It should come from the nature of your problem.

You can start with uniform timestep. For example, t=linspace(0,50,10000).

I did a quick Google search on adaptive timesteps and the first few links seem rather good. Starting with an educational writing illustrating the concept using Euler's method.

ode45 uses adaptive timesteps of its own choosing. Their method is described in the first linked article.

The code below is for simulating the Rossler system.

Your odefun format is right. Ofc, since we communicate only in Minimal Reproducible Example, your coefficients must be right -- though that is something you may wish to double-check.

I do not have an opinion on whether the results below would be a correct solution. (I would not wish to.)

You can experiment with different tolerance values to see if a more sensible result can be produced.

Perhaps you will find it helpful to know that I have seen strange and incorrect results from ode45 from very simple systems when my manually implemented non-adaptive RK45 and even Euler method worked as expected.

If I were you, I would simultaneously engage in a conversation at math.stackexchange on why and when adaptive ODE methods converge. Perhaps that will give you insight as to why and when ode45 results may be highly inaccurate.

I want to generate a user defined N number of points.

ode45 will decide its own timesteps. Inputting an expanded t as opposed to just the end points tells ode45 to use the number of points you desire. It is also useful for telling ode45 to integrate backwards in time. Format for generating an 1-by-N vector is t=linspace(t0,tf,N). You do not need and cannot customize dt for ode45.


Using ode45, 100k points, your constants: 1

Using ode113, 100k points, a=0.2, and ode15s result looks similar: enter image description here

Argyll
  • 8,591
  • 4
  • 25
  • 46