EQ overloads the == operator for xydata objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: EQ overloads the == operator for xydata 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 xydata objects exc_list - exception list List of properties which are not checked. OUTPUTS: If the two xydata 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 xydata objects. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EQ overloads the == operator for xydata 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 xydata objects 0020 % exc_list - exception list 0021 % List of properties which are not checked. 0022 % 0023 % OUTPUTS: If the two xydata 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, ['xydata/' 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 0069 % function result = eq(c1,c2, varargin) 0070 % 0071 % % EQ overloads the == operator for xydata objects. 0072 % % 0073 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0074 % % 0075 % % DESCRIPTION: EQ overloads the == operator for xydata objects. 0076 % % 0077 % % The 'name', 'xunits, 'yunits, and data values are checked. 0078 % % 0079 % % CALL: result = eq(c1,c2) 0080 % % 0081 % % INPUTS: c1,c2 - input xydata objects 0082 % % 0083 % % OUTPUTS: If the two xydata objects are considered equal, result == 1, 0084 % % otherwise, result == 0. 0085 % % 0086 % % VERSION: $Id: param.m,v 1.7 2007/08/17 11:22:11 ingo Exp $ 0087 % % 0088 % % HISTORY: 29-08-2007 M Hewitson 0089 % % Creation 0090 % % 0091 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0092 % 0093 % % Assume equality to begin with 0094 % result = 1; 0095 % 0096 % %% Check name 0097 % if ~ismember('name', varargin) 0098 % if ~strcmp(c1.name, c2.name) 0099 % result = 0; 0100 % return 0101 % end 0102 % end 0103 % 0104 % %% check xunits 0105 % if ~ismember('xunits', varargin) 0106 % if ~strcmp(c1.xunits, c2.xunits) 0107 % result = 0; 0108 % return 0109 % end 0110 % end 0111 % 0112 % %% check yunits 0113 % if ~ismember('yunits', varargin) 0114 % if ~strcmp(c1.yunits, c2.yunits) 0115 % result = 0; 0116 % return 0117 % end 0118 % end 0119 % 0120 % %% Check x data 0121 % if ~ismember('x', varargin) 0122 % if length(c1.x) ~= length(c2.x) 0123 % result = 0; 0124 % return 0125 % end 0126 % 0127 % if c1.x ~= c2.x 0128 % result = 0; 0129 % return 0130 % end 0131 % end 0132 % 0133 % %% Check y data 0134 % if ~ismember('y', varargin) 0135 % if length(c1.y) ~= length(c2.y) 0136 % result = 0; 0137 % return 0138 % end 0139 % 0140 % if c1.y ~= c2.y 0141 % result = 0; 0142 % return 0143 % end 0144 % end