-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathsaveframe.m
More file actions
48 lines (39 loc) · 1.61 KB
/
Copy pathsaveframe.m
File metadata and controls
48 lines (39 loc) · 1.61 KB
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
42
43
44
45
46
47
48
function saveframe(flagoutput, direc, filename, saveplot_fmt, h)
%% CREATES IMAGE FILES FROM PLOTS
narginchk(5,5)
validateattributes(flagoutput, {'numeric'}, {'scalar'}, mfilename)
validateattributes(direc, {'char'}, {'vector'}, mfilename)
validateattributes(filename, {'char'}, {'vector'}, mfilename)
validateattributes(h, {'struct'}, {'vector'}, mfilename)
if ischar(saveplot_fmt), saveplot_fmt = {saveplot_fmt}; end
assert(isfolder(direc), [direc, ' is not a directory.'])
% filename has the suffix, let's ditch the suffix.
[~, stem] = fileparts(filename);
plotdir = [direc, '/plots'];
if ~isfolder(plotdir)
[status, msg] = mkdir(plotdir);
assert(status==0, ['could not create directory ', plotdir, ' ', msg])
end
disp(['writing plots to ', plotdir])
for i=1:length(saveplot_fmt)
switch saveplot_fmt{i}
case 'png', flag = '-dpng'; suffix = '.png';
case 'eps', flag = '-depsc2'; suffix = '.eps';
otherwise, continue
end
if flagoutput~=3
print(h.f1,flag,[plotdir, '/v1-', stem, suffix],'-r300')
print(h.f2,flag,[plotdir, '/Ti-', stem, suffix],'-r300')
print(h.f3,flag,[plotdir, '/Te-', stem, suffix],'-r300')
print(h.f4,flag,[plotdir, '/J1-', stem, suffix],'-r300')
print(h.f5,flag,[plotdir, '/v2-', stem, suffix],'-r300')
print(h.f6,flag,[plotdir, '/v3-', stem, suffix],'-r300')
print(h.f7,flag,[plotdir, '/J2-', stem, suffix],'-r300')
print(h.f8,flag,[plotdir, '/J3-', stem, suffix],'-r300')
if ~isempty(h.f9)
print(h.f9,flag,[plotdir, '/Phitop-', stem, suffix],'-r300')
end
end
print(h.f10,flag,[plotdir, '/ne-', stem, suffix],'-r300')
end % for
end % function