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