I am going to develop an unsteady diffusion calculation in Mathematica. Because it is unsteady, I would like to visualize the solution each time step (or in some time steps). My MATLAB skills are much better than Mathematica, so I am going to give the example from there. I looked at some of the posts about that, but they were for small number of time steps like 10, or saving each plot and creating a movie. But in MATLAB I can do
surf(x,z,U_sol)
F=getframe;
x
and z
are the position vectors and U_sol
is the solution matrix. GetFrame
simply preserves frame but not the plot, so it looks like a continuous plotting, like a movie.
In Matlab, you can do something like this to save the movie directly. This is before time steps
fid=figure;
pos=get(fid,'position');
writerObj=VideoWriter('sol.avi');
writerObj.FrameRate=10;
open(writerObj);
and inside the time loop
PLOT...
frame=getframe(gcf);
writeVideo(writerObj,frame)
and at the end of the time loop.
close (writerObj)
and you will have the movie file without dealing with each frame. There should be some equivalent version in Mathematica.
ListPlot3D[]
(orPlot3D[]
if you're usingNDSolve[]
for the PDE),Animate[]
, and/orExport[]
... $\endgroup$Export
on a frame by frame basis, you need to compile all frames as a list andExport
all at once. $\endgroup$Monitor
$\endgroup$