


EQ overloads the == operator for pzmodel objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: EQ overloads the == operator for pzmodel 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 pzmodel objects
exc_list - exception list
List of properties which are not checked.
OUTPUTS: If the two pzmodel objects are considered equal, result == 1,
otherwise, result == 0.
VERSION: $Id: eq.m,v 1.5 2008/01/07 18:18:18 ingo Exp $
HISTORY: 29-08-2007 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function result = eq(c1,c2, varargin) 0002 % EQ overloads the == operator for pzmodel objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: EQ overloads the == operator for pzmodel objects. 0007 % 0008 % All fields are checked. 0009 % 0010 % CALL: result = eq(c1,c2) 0011 % result = eq(c1,c2, exc_list) 0012 % result = eq(c1,c2, 'property1', 'property2') 0013 % result = eq(c1,c2, 'class/property', 'class/property') 0014 % 0015 % EXAMPLES: result = eq(c1,c2, 'name', 'created') 0016 % result = eq(c1,c2, 'ao/name') 0017 % 0018 % INPUTS: c1,c2 - input pzmodel objects 0019 % exc_list - exception list 0020 % List of properties which are not checked. 0021 % 0022 % OUTPUTS: If the two pzmodel objects are considered equal, result == 1, 0023 % otherwise, result == 0. 0024 % 0025 % VERSION: $Id: eq.m,v 1.5 2008/01/07 18:18:18 ingo Exp $ 0026 % 0027 % HISTORY: 29-08-2007 M Hewitson 0028 % Creation 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 VERSION = '$Id: eq.m,v 1.5 2008/01/07 18:18:18 ingo Exp $'; 0033 0034 % Check if this is a call for parameters 0035 if nargin == 2 0036 if isa(c1, 'pzmodel') && ischar(c2) 0037 in = char(c2); 0038 if strcmp(in, 'Params') 0039 result = plist; 0040 return 0041 elseif strcmp(in, 'Version') 0042 result = VERSION; 0043 return 0044 end 0045 end 0046 end 0047 0048 result = 1; 0049 0050 %% Check class 0051 if ~strcmp(class(c1), class(c2)) 0052 result = 0; 0053 return 0054 end 0055 0056 fields = fieldnames(c1); 0057 0058 for ii = 1:length(fields) 0059 field = fields{ii}; 0060 0061 ck_field = {field, ['pzmodel/' field]}; 0062 0063 %% Check tag 0064 if ~(any(ismember(ck_field, varargin))) 0065 0066 if isobject(c1.(field)) 0067 0068 if length(c1.(field)) ~= length(c2.(field)) 0069 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0070 result = 0; 0071 return 0072 end 0073 0074 for jj = 1:length(c1.(field)) 0075 if ~eq(c1.(field)(jj), c2.(field)(jj), varargin{:}) 0076 result = 0; 0077 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0078 return 0079 end 0080 end 0081 else 0082 if ~isequalwithequalnans(c1.(field), c2.(field)) 0083 result = 0; 0084 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0085 return 0086 end 0087 end 0088 0089 end 0090 end 0091