-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaptSave.m
More file actions
47 lines (40 loc) · 1.12 KB
/
Copy pathaptSave.m
File metadata and controls
47 lines (40 loc) · 1.12 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
function aptSave(folderName,saveFigures)
%APTSAVE saves apt variable to workspace. Also saves figures if flag is set.
global apt
if ~exist('folderName','var')
prompt = 'Please enter the name of the savefolder:\n';
folderName = input(prompt,'s');
end
if ~exist('saveFigures','var')
saveFigures = false;
end
wd = pwd;
if ~isdir('Results')
mkdir('Results')
end
pathtofolder = [wd '/Results/' folderName];
cd Results
if ~isdir(folderName)
mkdir(folderName);
end
cd(wd)
apt.savepath = pathtofolder;
save([pathtofolder '/workspace.mat'],'apt')
if isfile('Results.txt')
copyfile('Results.txt', pathtofolder)
end
% save figures
if saveFigures
FolderName = pathtofolder; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = get(FigHandle, 'Name');
if isempty(FigName)
FigName = ['Figure' num2str(iFig)];
end
savefig(FigHandle, fullfile(FolderName, [FigName, '.fig']));
print(FigHandle,fullfile(FolderName, FigName),'-dpng','-r300')
end
end
end