-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCl_GetClusterContent.m
43 lines (36 loc) · 1.91 KB
/
Cl_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
function [ values ] = Cl_GetClusterContent( path, file, se, searchstring )
%GETCLUSTERCONTENT returns an array of all seachstring sub values
% This method extracts all subfeatures of a given searchstring.
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).name ~= '.') & (mainFolder(i).name ~= '..') )
if (strcmp(num2str(mainFolder(i).name), '.')~=1 ) % and then, only if it's a real folder
if (strcmp(num2str(mainFolder(i).name), '..')~=1 ) % and then, only if it's a real folder
%which path we are operating on
% innerPath = strcat(path, '/', mainFolder(i).name); %e.g. 'Tablare/1'
% subFolder = dir(innerPath);
% for j=1:length(subFolder) % iterate through the subfolder (the innerPath)
if (strcmp(num2str(mainFolder(i).name), completeFile)==1 )%if we found a .mat file
%load the file
S = load(strcat(path,'/',completeFile));
% structure contains all fields of the stored struct
% e.g. Coordinates, Name, Picture, isEmpty, etc.
structure = getfield(S,'S');
% inner only holds all values related to the searchstring
inner = getfield(structure, searchstring);
% values contains all different values for the searchstring
values = fieldnames(inner);
break
end
% end
%Added, because if we have already found our values, we don't need
%to proceed
% if isempty(values) == 0
% break;
% end
end
end
end
end