About saving output at specific time steps with an ODE solver

Hi there,
I am running matlab ODE function and saving the integrated solution in a file. Each file comes out to be around 1 GB. I do not need the solution (output) barring at a few times during the run. Is there a way to save only these times and the respective output instead of output at each time step? I have an idea of trying to save the output by using a for loop after every run e.g.
T_out=[0 10 20 30...] ; %...time vector of steps at which output needs to b saved
[T out] = ode15s(....); for i-1:length(T_out) if(T==T_out)
save out to file end....
But this takes a lot of time given that there are at times 100000 time steps in the solver output. Is there a faster way to do this ?
Thanks

Réponses (2)

TUSHAR ANDRIYAS
TUSHAR ANDRIYAS le 20 Déc 2012
Tspan is defined seperately as Tspan=[0 1000]. I let the adaptive scheme do its thing and the differential eqs are solved in a for loop 200 times.
Tspan = [0 1000];
T_out= 0:10:1000;%...create vector of time steps at which out is saved
y0=....; %initial cond
for j = 1:200 %....solve for 200 initial cond
[T out] = ode15s(@fn,Tspan, options, y0);
%then go into the T vector to search for when T==T_out for k=1:length(T) for i=1:length(T_out) if(T(k)==T_out(i))
save out values to file
What I want is that when the ode solver solves for trajectories, it should save the trajectory at some pre specified times as shown above..... Sorry for the hazy picture given before and hope this will help
Thanks, Tushar
How do you define the input TSPAN for the ODE45 command? Would this help already:
[T, out] = ode15s(@fcn, T_out, y0)
If not, please explain the problem again. Why do you call a FOR loop and how does it look exactly?

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by