Until now, I have been using the following approach to create animations:
using Plots anim = Animation(); for it = 1:nt # Computations # ... # Visualization (e.g. every 10th time step) if mod(it,10)==0 contourf(...); frame(anim); end end gif(anim, "test.gif", fps = 15);
Once, the simulation has finished, this creates an animated gif.
How can I modify this code to have it write out the animation incrementally after each call to
frame(anim) instead of having it written only at the end?
Then, one could see already during the simulation if it goes as expected or not and in case of a crash one would at least have a partial animation to inspect.
E.g. in MATLAB this is possible with
imwrite, using the
The full MATLAB example is here.