Save a figure to a file, without having to use the window.
%% Defauxt printing figure command (won't show the plot) figure(1); set(gcf, 'Visible', 'off'); plot(x, x.^2/2); print(gcf, '-dpdf', 'figure1.pdf');