-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsCollectLHS.m
61 lines (54 loc) · 1.9 KB
/
psCollectLHS.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
% ars = psCollectLHS(pfad,minsize)
%
% This function recursively searches a path and collects all ar structs
% containting lhs fits.
%
% All workspaces *.mat ar searched for a variable ar. Then existance and
% size of ar.chi2s checked. If more than minsize fits are availabel, the
% the variable ar is collected in the cell-array ars.
%
% pfad Path where recursive search should start.
% Default pfad = pwd
%
% minsize minimal sample size (number of fits) of LHS,
% i.e. selection if length(ar.chi2s)>= minsize
% Default: minsize = 100
function ars = psCollectLHS(pfad,minsize,deleteDuplicates)
if ~exist('pfad','var') || isempty(pfad)
pfad = pwd;
end
if ~exist('minsize','var') || isempty(minsize)
minsize = 100; % minimal number of lhs fits
end
if ~exist('deleteDuplicates','var') || isempty(deleteDuplicates)
deleteDuplicates = false;
end
folders = dir_FoldersRecursive(pfad);
folders = [{pfad},folders];
ars = cell(0);
for f=1:length(folders)
if deleteDuplicates
psRemoveLhsDuplicates(folders{f})
end
d = dir(folders{f});
d = d([d.isdir]==0);
matfiles = {d(find(~cellfun(@isempty,regexp({d.name},'\.mat$')))).name};
for m=1:length(matfiles)
tmpfolder = [folders{f},filesep,matfiles{m}];
fprintf('%s',[tmpfolder,' ... '])
tmp = load(tmpfolder);
treffer = 0;
if isfield(tmp,'ar')
if isfield(tmp.ar,'chi2s') && isfield(tmp.ar,'checkstr') && length(tmp.ar.chi2s)>=minsize
ars{end+1} = tmp.ar;
ars{end}.folder = [folders{f},filesep,matfiles{m}];
treffer = 1;
end
end
if treffer
fprintf('\n -> %i LHS fits found.\n',length(tmp.ar.chi2s));
else
fprintf(' nothing found.\n');
end
end
end