-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsaveFigDesktop.m
More file actions
34 lines (28 loc) · 969 Bytes
/
saveFigDesktop.m
File metadata and controls
34 lines (28 loc) · 969 Bytes
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
function saveFigDesktop(figHdl, fileName)
% saveFigDesktop: save plot figure to your Desktop directory as vector PDF
%
% [Syntax]
% saveFigDesktop(figHandle)
% saveFigDesktop(figHandle, fineName)
%
% [Input]
% figHdl: figure handle of plot graph
% fileName: output file name WITHOUGHT ".pdf" (string)
%
% Check arguments and set default values
arguments
figHdl
fileName (1,1) {mustBeNonzeroLengthText} = "out"
end
% Get user name of your PC
userName = extractBetween(userpath, "C:\Users\", "\");
% Produce file path on Desktop
outFilePath = "C:\Users\" + userName{:} + "\Desktop\" + fileName + ".pdf";
% Get paper position from input figure handle
figPos = figHdl.PaperPosition;
% Define paper size
figHdl.PaperSize = figPos(3:4);
% Save figure file as vector .pdf format
print(figHdl, outFilePath, "-bestfit", "-dpdf", "-vector");
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%