saving figures in matlab

7 views (last 30 days)
MINA
MINA on 23 May 2016
Answered: Richard Quist on 24 May 2016
Hello.
I am generating bunch of figures in matlab which is in a for loop. I would like to save them both in .fig and .jpg. Right now I am first plotting the figure and then save them. But I don't really need to see the figures and I just want to save them. Is there anyway that I do this so that the speed increases?
Thanks

Answers (2)

Richard Quist
Richard Quist on 24 May 2016
You can try using an invisible figure:
% create an invisible figure
f = figure('visible', 'off');
% loop 10 times, saving .fig and .jpeg for a random plt
for idx = 1:10
% plot your data
plot(rand(10));
% save as .fig
savefig(f, sprintf('figure%d.fig', idx));
% save as jpeg
print(f, '-djpeg', sprintf('figure%d.jpg', idx));
% clear the figure
clf(f);
end
delete(f);

Image Analyst
Image Analyst on 24 May 2016
Put
drawnow
right after you display the images. If it's still too fast, put in a
pause(0.3)
to delay it a little bit.
Don't save as .fig or .jpg. Save the axes as a .PNG. I recommend you use export_fig. http://blogs.mathworks.com/pick/2010/05/28/creating-and-exporting-publication-quality-graphics/

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!