Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Wednesday, June 04, 2008

Export figures in Matlab without displaying them

Assuming you have a lot of figures to plot, but you do not want to wait and see them in Matlab's figure window. There is a way you can export all of your figures without displaying them. This might also save you some time, since you are drawing them on the screen.

Here is how :

% Create a figure with visibility off
f = figure('Visible','off');
% Then do your plot
plot
% Finally export the plot as an image
print('-dpng', 'test.png');

You can also make this in a loop (Which is very probable if you have too many figures).
Do this

for i:1, n
f = figure('Visible','off');
plot
filename = sprintf('plot-%d',i);
print('-dpng', filename);
end

This will give you 'n' png images with your plots in it.

Wednesday, January 16, 2008

Creating an image from a TeX file

To create an image from a Latex file do the following :

$>latex --interaction=nonstopmode file.tex

$>dvips -E file.dvi -o file.ps

$>convert -density 200 file.ps file.png

Violaaaa;

Note that convert is a command line utility that comes with ImageMagick installation.