How do I save only the final state of ode solver?

8 Ansichten (letzte 30 Tage)
Sergio Picella
Sergio Picella am 22 Mai 2020
Kommentiert: Sergio Picella am 22 Mai 2020
Hi all, first question here so sorry for being a bit clumsy in my notation: I am trying to solve a stiff problem using ode113 like in the following lines (J is e.g. a 50*50 matrix) and would like to save the configurations every given (k) time steps (regardless the exact time value, just to plot after the general outline of the solutions in time). My procedure so far was to wait for the ode113 to be done and then sampling my output from R and T.
As I am having memory pressure issues and I reasonably enough hit the maximum array size, I would like to save the state at a given iteration and its time while the simulation is running, without waiting for the whole ode113 to be done and picking the values from the whole R and T.
Can anybody suggest an efficient procedure?
Thanks in advance to all the community!
Sergio
[On top of that: how can I save only the final state of the ode113?]
opt.OutputFcn = @output;
opt.Jacobian = @(t,F) J;
opt.AbsTol = 1e-50;
opt.stats = 1;
opt.RelTol = 1e-13;
t_end = 1e4;
while time<t_end
[T, R]=ode113( @(t,x) J*x, [time t_end], Z, opt );
opt.InitialStep = T( end ) - T( end-1 );
time = T(end);
Z = R( end, : )';
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Mai 2020
use options for plotfcn or outputfcn and have it skip updating the plot unless the iteration number mod n is 0.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by