Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save Matlab figure without plotting it?

Is there a way of saving a figure plot without actually plotting it? I mean, let's say I want to save the graph for plot(1:10, (1:10).^2), can I save it without showing it?

I want to make the run time shorter by cutting off the unnecessary plotting of the figures (those will be closed anyway after saving).

Thanks!

like image 788
shahar_m Avatar asked Apr 28 '11 12:04

shahar_m


2 Answers

This can be done:

set(gcf,'Visible','off');
plot((1:10),(1:10).^2);
print -dpng c:\chris.png  % or whatever your print command is
like image 84
Chris A. Avatar answered Nov 16 '22 02:11

Chris A.


There is also the saveas(h,'filename.ext') function which can save a figure in some formats.

like image 45
Mohsen Avatar answered Nov 16 '22 03:11

Mohsen