OptFEM2DP1 Toolbox  V1.2b3
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 2D
 All Files Functions Pages
SaveFigure.m
Go to the documentation of this file.
1 function SaveFigure(issave,Name,percent)
2 % function SaveFigure(issave,Name,percent)
3 % To manage the saving of figures. Save in eps, jpg and png format.
4 %
5 % Parameters:
6 % issave: boolean. If true saving figure is done.
7 % Name: name of the destination file without extension (string)
8 % percent: value for resizing the figure (only png format under unix)
9 %
10 % Copyright:
11 % See \ref license
12 if issave
13  [SUCCESS,MESSAGE,MESSAGEID] = mkdir('images');
14  eval(sprintf('print -depsc2 images/%s.eps',Name))
15  fprintf(' -> save figure(%d) in images/%s.eps\n',gcf,Name);
16  eval(sprintf('print -djpeg90 images/%s.jpg',Name))
17  fprintf(' -> save figure(%d) in images/%s.jpg\n',gcf,Name);
18  if isunix
19  system(sprintf('convert -resize %d%% images/%s.eps images/%s.png',percent,Name,Name));
20  fprintf(' -> save figure(%d) in images/%s.png (resize %d%%)\n',gcf,Name,percent);
21  else
22  eval(sprintf('print -dpng images/%s.png',Name))
23  fprintf(' -> save figure(%d) in images/%s.png \n',gcf,Name);
24  end
25 end