-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetClusterContent.m
89 lines (76 loc) · 2.67 KB
/
GetClusterContent.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function [ values ] = Cl_GetClusterContent( path, file, se, searchstring )
%GETCLUSTERCONTENT returns an array of all seachstring sub values
% Detailed explanation goes here
mainFolder = dir(path);
completeFile = strcat(file, se); %e.g. 'S.mat' (stored data)
for i=1:length(mainFolder) %iterate through the whole folder
% only go inside if it is a directory
if (mainFolder(i).isdir & (mainFolder(i).name ~= '.') & (mainFolder(i).name ~= '..') )
%which path we are operating on
innerPath = strcat(path, '/', mainFolder(i).name); %e.g. 'Tablare/1'
subFolder = dir(innerPath);
for j=1:length(subFolder)
%if we found a .mat file
if (strcmp(subFolder(j).name, completeFile))
%load file
S = load(strcat(innerPath,'/',completeFile));
values = extractValues(S);
break
end
end
% n = str2double(S.number);
% if (isLaws)
% data(n).values = esd;
% structure(n) = length(esd);
% else
%
% data(n).values = da;
% structure(n) = length(da);
% end
end
end
end
%% Function extractValues
function [values] = extractValues(S)
parts = regexp(c1,'\.','split'); %extract parts of c1 (desired content)
parts2 = regexp(c2,'\.','split'); %extract parts of c2 (desired content)
if (length(parts)>=2 && length(parts2)>=2) % both have two parts in their name
for x=1:length(S);
if S(x).determined == false
a= getfield(S(x),char(parts(1)), char(parts(2)));
b= getfield(S(x),char(parts2(1)), char(parts2(2)));
switch length(a)
case 1
innerData(x,1) = a;
case 2
innerData(x,1) = a(1);
innerData(x,2) = a(2);
otherwise
return;
end
switch length(b)
case 1
innerData(x,2) = b;
case 2
innerData(x,1) = b(1);
innerData(x,2) = b(2);
otherwise
return;
end
%
% innerData(x,1) = getfield(S(x),char(parts(1)), char(parts(2)));
% innerData(x,2) = getfield(S(x),char(parts2(1)), char(parts2(2)));
else
innerData(x,:) = 0;
end
end
else
for x=1:length(S);
if S(x).determined == false
innerData(x) = getfield(S(x),content);
else
innerData(x,:) = 0;
end
end
end
end