From: Ubaldo Tiberi on
Hi everyboby,

I have got some time problem with a simulation. I have something like this:

X1=[];
Time=[];

for ii=1:50000
Compute T(ii)
[X T]=ode45(@(t,x) model(foo1,foo2,....),T(ii),.....)
X1=[X1;X]
Time=[Time;T]
end

At each iteration:
1) I compute a time interval for which the function defined in model.m must be integrated
2) I store the value of the state in X1 and of the time in Time.

When the number of iterations become "big", the simulation gets very very slow. I was thinking to preallocate the values of Time and X1, but I don't know at each iteration how big will be the vector X and T. How can I speed up my simulations?

Thank you,
Ubaldo
--