EQ overloads the == operator for param objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: EQ overloads the == operator for param objects. The 'key' and 'val' fields are checked. CALL: result = eq(p1,p2) INPUTS: p1,p2 - input param objects OUTPUTS: If the two param objects are considered equal, result == 1, otherwise, result == 0. VERSION: $Id: param.m,v 1.7 2007/08/17 11:22:11 ingo Exp $ HISTORY: 29-08-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function result = eq(p1,p2) 0002 0003 % EQ overloads the == operator for param objects. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EQ overloads the == operator for param objects. 0008 % 0009 % The 'key' and 'val' fields are checked. 0010 % 0011 % CALL: result = eq(p1,p2) 0012 % 0013 % INPUTS: p1,p2 - input param objects 0014 % 0015 % OUTPUTS: If the two param objects are considered equal, result == 1, 0016 % otherwise, result == 0. 0017 % 0018 % VERSION: $Id: param.m,v 1.7 2007/08/17 11:22:11 ingo Exp $ 0019 % 0020 % HISTORY: 29-08-2007 M Hewitson 0021 % Creation 0022 % 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 0025 % Assume equality to begin with 0026 result = 1; 0027 0028 %% check key 0029 if ~strcmp(p1.key, p2.key) 0030 result = 0; 0031 return 0032 end 0033 0034 %% check value 0035 0036 % do we have objects to compare? 0037 if isobject(p1.val) || isobject(p2.val) 0038 if ~isobject(p2.val) || ~isobject(p2.val) 0039 result = 0; 0040 return 0041 else 0042 if ~eq(p1.val, p2.val) 0043 result = 0; 0044 return 0045 end 0046 end 0047 else 0048 % normal comparison 0049 if ischar(p1.val) || ischar(p2.val) 0050 if ~ischar(p1.val) || ~ischar(p2.val) 0051 result = 0; 0052 return 0053 else 0054 if ~strcmp(p1.val, p2.val) 0055 result = 0; 0056 return 0057 end 0058 end 0059 else 0060 if p1.val ~= p2.val 0061 result = 0; 0062 return 0063 end 0064 end 0065 end