Thomas Dehaeze
6e3677eb29
Folder name is changed, rework the html templates Change the organisation.
49 lines
1.3 KiB
Matlab
49 lines
1.3 KiB
Matlab
% This function exports the given figure with nice settings to the given
|
|
% file path in the defined file format.
|
|
%
|
|
% input parameter:
|
|
% - handle ... figure handle
|
|
% - path ... file path
|
|
% - format ... file format ('pdf', 'meta', 'jpeg', 'png'), default 'pdf'
|
|
|
|
function exportFigure(handle, path, format)
|
|
|
|
% select figure
|
|
figure(handle)
|
|
|
|
% set output settings
|
|
set(gcf, 'PaperPositionMode', 'manual', 'Renderer', 'painters', 'RendererMode', 'manual');
|
|
|
|
|
|
% export figure
|
|
print(handle, path, '-dpdf');
|
|
|
|
% set export format
|
|
% if(strcmp(format,'pdf') || strcmp(format,'jpeg') )
|
|
% dformat = ['-d' format];
|
|
% else
|
|
% dformat = '-dpdf';
|
|
% end
|
|
%
|
|
% if(strcmp(format,'meta'))
|
|
% format = 'emf';
|
|
% end
|
|
%
|
|
% if(strcmp(format,'jpeg'))
|
|
% format = 'jpg';
|
|
% end
|
|
|
|
if(strcmp(format,'jpeg') || strcmp(format,'jpg') || ...
|
|
strcmp(format,'JPEG') || strcmp(format,'JPG'))
|
|
display(' --------------- Converting to JPG image ----------------- ');
|
|
system(['convert -density 300 ' path '.pdf -quality 95 ' path '.jpg']);
|
|
system(['rm ' path '.pdf']);
|
|
end
|
|
|
|
if(strcmp(format,'png') || strcmp(format,'PNG'))
|
|
display(' --------------- Converting to PNG image ----------------- ');
|
|
system(['convert -density 300 ' path '.pdf ' path '.png']);
|
|
system(['rm ' path '.pdf']);
|
|
end
|
|
|
|
end % end function |