IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
uniquenesses.m
Go to the documentation of this file.
1 %>@ingroup string conversion
2 %> @file
3 %> @brief Extract unique part of each string within a cell
4 %>
5 %> Iterates through the strings to find a piece in the middle that is different in each string.
6 %>
7 %> Update 18/06/2013: Removes all matches of (...) from strings before
8 %>
9 %> @param cc Cell of strings
10 %> @return dd Cell of strings
11 function dd = uniquenesses(cc)
12 n = numel(cc);
13 for i = 1:n
14  cc{i} = regexprep(cc{i}, '\([a-zA-Z0-9]*\)', '');
15 end;
16 
17 nn = cellfun(@numel, cc);
18 bk = 1;
19 flag_break = 0;
20 while 1
21  for i = 1:n
22  if bk > nn(i)
23  flag_break = 1;
24  break;
25  end;
26  if i == 1
27  ch = cc{i}(bk);
28  else
29  if cc{i}(bk) ~= ch
30  flag_break = 1;
31  break;
32  end;
33  end;
34  end;
35  if flag_break
36  break;
37  end;
38  bk = bk+1;
39 end;
40 
41 
42 ck = 0;
43 flag_break = 0;
44 while 1
45  for i = 1:n
46  if nn(i)-ck < 1
47  flag_break = 1;
48  break;
49  end;
50  if i == 1
51  try
52  ch = cc{i}(end-ck);
53  catch me
54  sdfs;
55  end;
56  else
57  if cc{i}(end-ck) ~= ch
58  flag_break = 1;
59  break;
60  end;
61  end;
62  end;
63  if flag_break
64  break;
65  end;
66  ck = ck+1;
67 end;
68 
69 
70 
71 for i = 1:n
72  dd{i} = cc{i}(bk:end-ck);
73 end;
function uniquenesses(in cc)