


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: eq.m,v 1.6 2007/11/27 13:07:28 ingo Exp $
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: eq.m,v 1.6 2007/11/27 13:07:28 ingo Exp $ 0027 % 0028 % HISTORY: 29-08-2007 M Hewitson 0029 % Creation 0030 % 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 VERSION = '$Id: eq.m,v 1.6 2007/11/27 13:07:28 ingo Exp $'; 0034 0035 % Check if this is a call for parameters 0036 if nargin == 2 0037 if isa(c1, 'xydata') && 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 result = 1; 0050 0051 %% Check class 0052 if ~strcmp(class(c1), class(c2)) 0053 result = 0; 0054 return 0055 end 0056 0057 fields = fieldnames(c1); 0058 0059 for ii = 1:length(fields) 0060 field = fields{ii}; 0061 0062 ck_field = {field, ['xydata/' field]}; 0063 0064 %% Check tag 0065 if ~(any(ismember(ck_field, varargin))) 0066 0067 if isobject(c1.(field)) 0068 if ~eq(c1.(field), c2.(field), varargin{:}) 0069 result = 0; 0070 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0071 return 0072 end 0073 else 0074 if ~isequalwithequalnans(c1.(field), c2.(field)) 0075 result = 0; 0076 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0077 return 0078 end 0079 end 0080 0081 end 0082 end 0083 0084 0085 % function result = eq(c1,c2, varargin) 0086 % 0087 % % EQ overloads the == operator for xydata objects. 0088 % % 0089 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0090 % % 0091 % % DESCRIPTION: EQ overloads the == operator for xydata objects. 0092 % % 0093 % % The 'name', 'xunits, 'yunits, and data values are checked. 0094 % % 0095 % % CALL: result = eq(c1,c2) 0096 % % 0097 % % INPUTS: c1,c2 - input xydata objects 0098 % % 0099 % % OUTPUTS: If the two xydata objects are considered equal, result == 1, 0100 % % otherwise, result == 0. 0101 % % 0102 % % VERSION: $Id: eq.m,v 1.6 2007/11/27 13:07:28 ingo Exp $ 0103 % % 0104 % % HISTORY: 29-08-2007 M Hewitson 0105 % % Creation 0106 % % 0107 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0108 % 0109 % % Assume equality to begin with 0110 % result = 1; 0111 % 0112 % %% Check name 0113 % if ~ismember('name', varargin) 0114 % if ~strcmp(c1.name, c2.name) 0115 % result = 0; 0116 % return 0117 % end 0118 % end 0119 % 0120 % %% check xunits 0121 % if ~ismember('xunits', varargin) 0122 % if ~strcmp(c1.xunits, c2.xunits) 0123 % result = 0; 0124 % return 0125 % end 0126 % end 0127 % 0128 % %% check yunits 0129 % if ~ismember('yunits', varargin) 0130 % if ~strcmp(c1.yunits, c2.yunits) 0131 % result = 0; 0132 % return 0133 % end 0134 % end 0135 % 0136 % %% Check x data 0137 % if ~ismember('x', varargin) 0138 % if length(c1.x) ~= length(c2.x) 0139 % result = 0; 0140 % return 0141 % end 0142 % 0143 % if c1.x ~= c2.x 0144 % result = 0; 0145 % return 0146 % end 0147 % end 0148 % 0149 % %% Check y data 0150 % if ~ismember('y', varargin) 0151 % if length(c1.y) ~= length(c2.y) 0152 % result = 0; 0153 % return 0154 % end 0155 % 0156 % if c1.y ~= c2.y 0157 % result = 0; 0158 % return 0159 % end 0160 % end