-
Notifications
You must be signed in to change notification settings - Fork 1
/
print_fig.m
42 lines (36 loc) · 972 Bytes
/
print_fig.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [] = print_fig(fig, fname, ptype)
%PRINT_FIG This function is responsible for printing the figure to
% `fname` using `ptype` (default is `-dpng`)
%
% Author: Andreas Grammenos ([email protected])
%
% Last touched date: 30/12/2018
%
% License: GPLv3
%
% let the function know of these global vars
global pflag
global pdf_print
global fig_print
global graphPath
% check if we have a ptype argument
if nargin < 3
ptype = '-dpng'; % change to "-dpdf" for pdf
end
% check if we are allowed to print
if pflag == 1
% generate the full path by concat the graph path + fname
p = strcat(graphPath, fname);
% check if we are saving in a .fig format
if fig_print == 1
savefig(fig, char(p));
end
% print normally (as an image)
print(fig, char(p), ptype);
% check if we have a global flag that we print to pdf as well
if pdf_print == 1
ptype = '-dpdf'; % change to '-dpdf' due to global flag
print(fig, char(p), ptype);
end
end
end