


EQ overloads the == operator for analysis objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: EQ overloads the == operator for analysis objects.
All fields are checked.
CALL: result = eq(c1,c2)
result = eq(c1,c2, exc_list)
result = eq(c1,c2, 'property1', 'property2')
result = eq(c1,c2, 'class/property', 'class/property')
EXAMPLES: result = eq(c1,c2, 'name', 'created')
result = eq(c1,c2, 'ao/name')
INPUTS: c1,c2 - input analysis objects
exc_list - exception list
List of properties which are not checked.
OUTPUTS: If the two analysis objects are considered equal, result == 1,
otherwise, result == 0.
VERSION: $Id: eq.m,v 1.10 2007/11/23 12:11:08 ingo Exp $
HISTORY: 29-08-2007 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function result = eq(c1,c2, varargin) 0002 0003 % EQ overloads the == operator for analysis objects. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EQ overloads the == operator for analysis objects. 0008 % 0009 % All fields are checked. 0010 % 0011 % CALL: result = eq(c1,c2) 0012 % result = eq(c1,c2, exc_list) 0013 % result = eq(c1,c2, 'property1', 'property2') 0014 % result = eq(c1,c2, 'class/property', 'class/property') 0015 % 0016 % EXAMPLES: result = eq(c1,c2, 'name', 'created') 0017 % result = eq(c1,c2, 'ao/name') 0018 % 0019 % INPUTS: c1,c2 - input analysis objects 0020 % exc_list - exception list 0021 % List of properties which are not checked. 0022 % 0023 % OUTPUTS: If the two analysis objects are considered equal, result == 1, 0024 % otherwise, result == 0. 0025 % 0026 % VERSION: $Id: eq.m,v 1.10 2007/11/23 12:11:08 ingo Exp $ 0027 % 0028 % HISTORY: 29-08-2007 M Hewitson 0029 % Creation 0030 % 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 VERSION = '$Id: eq.m,v 1.10 2007/11/23 12:11:08 ingo Exp $'; 0034 0035 % Check if this is a call for parameters or for the cvs-version number 0036 if nargin == 2 0037 if isa(c1, 'ao') && ischar(c2) 0038 in = char(c2); 0039 if strcmp(in, 'Params') 0040 result = plist(); 0041 return 0042 elseif strcmp(in, 'Version') 0043 result = VERSION; 0044 return 0045 end 0046 end 0047 end 0048 0049 %% Check length of c1 and c2 0050 if length(c1) ~= length(c2) 0051 disp(sprintf('\nNOT EQUAL: The size of the ao''s')); 0052 result = 0; 0053 return 0054 end 0055 0056 %% Check class 0057 if ~strcmp(class(c1), class(c2)) 0058 disp(sprintf('\nNOT EQUAL: The class of the ao''s')); 0059 result = 0; 0060 return 0061 end 0062 0063 0064 %% for each element in c1 and c2 0065 for jj = 1:numel(c1) 0066 0067 result = 1; 0068 0069 fields = fieldnames(c1(jj)); 0070 0071 for ii = 1:length(fields) 0072 field = fields{ii}; 0073 0074 ck_field = {field, ['ao/' field]}; 0075 0076 % Is the field equal to history then add the name 'history' 0077 % to the exception list. 0078 if strcmp(field, 'hist') 0079 ck_field{end+1} = 'history'; 0080 ck_field{end+1} = 'ao/history'; 0081 end 0082 0083 %% Check fields 0084 if ~(any(ismember(ck_field, varargin))) 0085 0086 if isobject(c1(jj).(field)) 0087 if ~eq(c1(jj).(field), c2(jj).(field), varargin{:}) 0088 result = 0; 0089 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1(jj)), field)); 0090 return 0091 end 0092 else 0093 if ~isequalwithequalnans(c1(jj).(field), c2(jj).(field)) 0094 result = 0; 0095 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1(jj)), field)); 0096 return 0097 end 0098 end 0099 0100 end 0101 end 0102 0103 end 0104