EQ overloads the == operator for cdata objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: EQ overloads the == operator for cdata 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 cdata objects exc_list - exception list List of properties which are not checked. OUTPUTS: If the two cdata objects are considered equal, result == 1, otherwise, result == 0. VERSION: $Id$ HISTORY: 29-08-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function result = eq(c1,c2, varargin) 0002 0003 % EQ overloads the == operator for cdata objects. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EQ overloads the == operator for cdata 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 cdata objects 0020 % exc_list - exception list 0021 % List of properties which are not checked. 0022 % 0023 % OUTPUTS: If the two cdata objects are considered equal, result == 1, 0024 % otherwise, result == 0. 0025 % 0026 % VERSION: $Id$ 0027 % 0028 % HISTORY: 29-08-2007 M Hewitson 0029 % Creation 0030 % 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 result = 1; 0034 0035 %% Check class 0036 if ~strcmp(class(c1), class(c2)) 0037 result = 0; 0038 return 0039 end 0040 0041 fields = fieldnames(c1); 0042 0043 for ii = 1:length(fields) 0044 field = fields{ii}; 0045 0046 ck_field = {field, ['cdata/' field]}; 0047 0048 %% Check tag 0049 if ~(any(ismember(ck_field, varargin))) 0050 0051 if isobject(c1.(field)) 0052 if ~eq(c1.(field), c2.(field), varargin{:}) 0053 result = 0; 0054 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0055 return 0056 end 0057 else 0058 if ~isequalwithequalnans(c1.(field), c2.(field)) 0059 result = 0; 0060 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0061 return 0062 end 0063 end 0064 0065 end 0066 end 0067 0068 % function result = eq(c1,c2, varargin) 0069 % 0070 % % EQ overloads the == operator for cdata objects. 0071 % % 0072 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0073 % % 0074 % % DESCRIPTION: EQ overloads the == operator for cdata objects. 0075 % % 0076 % % All fields are checked. 0077 % % 0078 % % CALL: result = eq(c1,c2) 0079 % % 0080 % % INPUTS: c1,c2 - input cdata objects 0081 % % 0082 % % OUTPUTS: If the two cdata objects are considered equal, result == 1, 0083 % % otherwise, result == 0. 0084 % % 0085 % % VERSION: $Id: param.m,v 1.7 2007/08/17 11:22:11 ingo Exp $ 0086 % % 0087 % % HISTORY: 29-08-2007 M Hewitson 0088 % % Creation 0089 % % 0090 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 % 0092 % % Assume equality to begin with 0093 % result = 1; 0094 % 0095 % %% Check name 0096 % 0097 % if ~ismember('name', varargin) 0098 % if ~strcmp(c1.name, c2.name) 0099 % result = 0; 0100 % return 0101 % end 0102 % end 0103 % 0104 % %% Check vals 0105 % if ~ismember('vals', varargin) 0106 % if length(c1.vals) ~= length(c2.vals) 0107 % result = 0; 0108 % return 0109 % end 0110 % 0111 % if c1.vals ~= c2.vals 0112 % result = 0; 0113 % return 0114 % end 0115 % end