I have a plotting function in a for loop to go through data and produce a plot for each of them. Let's say the resultant figure contains huge amount of graphic objects, and very heavy in memory.
for i = 1:20 figure plot(rand(10,1),rand(10,1))end
In such cases, it would be useful, if one can keep only the screenshots of figures in a Live Script without keeping the bulky invisible figure objects open.
Hypothetically, if the code below could allow you to save snapshots in a Live Script, without actually keeping the figure object active, that might be convinient. The problem is that the code below will just close all the figures and nothing is shown in a Live Script.
for i = 1:20 figure plot(rand(10,1),rand(10,1)) drawnow closeend
This is the closest I could found. Actual plotting is postponed until the for loop finishses. But still the invisible figure objects are accumulating during the for loop.
for i = 1:20 figure plot(rand(10,1),rand(10,1)) drawnow limitrate enddrawnowclose all
Does anyone know to if keeping snapshots in a LiveScript without keeping figure objects is possible?
Best Answer