IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
compare.m
Go to the documentation of this file.
1 %> @file
2 %>@ingroup misc maths
3 %> @brief Shallow structure or cell comparison
4 %
5 %> @param o1
6 %> @param o2
7 %> @return flag
8 function flag = compare(o1, o2)
9 flag = 1;
10 if iscell(o1)
11  n = numel(o1);
12  for i = 1:n
13  if ~compare(o1{i}, o2{i})
14  flag = 0;
15  break;
16  end;
17  end;
18 elseif isstruct(o1)
19  ff = fields(o1);
20  for i = 1:numel(ff)
21  f = o1.(ff{i}); % value from 1st object
22  if ischar(f)
23  if ~strcmp(f, o2.(ff{i}))
24  flag = 0; break;
25  end;
26  else
27  if ~(f == o2.(ff{i}))
28  flag = 0; break;
29  end;
30  end;
31  end;
32 elseif ischar(o1)
33  flag = strcmp(o1, o2);
34 else
35  flag = eq(o1, o2);
36 end;
function compare(in o1, in o2)