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$ HISTORY: 29-08-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function result = eq(c1,c2, varargin) 0002 0003 % EQ overloads the == operator for pzmodel objects. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EQ overloads the == operator for pzmodel 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 pzmodel objects 0020 % exc_list - exception list 0021 % List of properties which are not checked. 0022 % 0023 % OUTPUTS: If the two pzmodel 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, ['pzmodel/' field]}; 0047 0048 %% Check tag 0049 if ~(any(ismember(ck_field, varargin))) 0050 0051 if isobject(c1.(field)) 0052 0053 if length(c1.(field)) ~= length(c2.(field)) 0054 result = 0; 0055 return 0056 end 0057 0058 for jj = 1:length(c1.(field)) 0059 if ~eq(c1.(field)(jj), c2.(field)(jj), varargin{:}) 0060 result = 0; 0061 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0062 return 0063 end 0064 end 0065 else 0066 if ~isequalwithequalnans(c1.(field), c2.(field)) 0067 result = 0; 0068 disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field)); 0069 return 0070 end 0071 end 0072 0073 end 0074 end 0075 0076 0077 % function result = eq(p1,p2) 0078 % 0079 % % EQ overloads the == operator for pzmodel objects. 0080 % % 0081 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0082 % % 0083 % % DESCRIPTION: EQ overloads the == operator for pzmodel objects. 0084 % % 0085 % % Checks that the pzmodel have identical pole/zero/gain values. 0086 % % 0087 % % CALL: result = eq(p1,p2) 0088 % % 0089 % % INPUTS: p1,p2 - input pzmodel objects 0090 % % 0091 % % OUTPUTS: If the two pzmodel objects are considered equal, result == 1, 0092 % % otherwise, result == 0. 0093 % % 0094 % % VERSION: $Id: param.m,v 1.7 2007/08/17 11:22:11 ingo Exp $ 0095 % % 0096 % % HISTORY: 29-08-2007 M Hewitson 0097 % % Creation 0098 % % 0099 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0100 % 0101 % % Assume they are equal 0102 % result = 1; 0103 % 0104 % %% Check gain 0105 % if p1.gain ~= p2.gain 0106 % result = 0; 0107 % return 0108 % end 0109 % 0110 % %% Check poles 0111 % 0112 % if length(p1.poles) ~= length(p2.poles) 0113 % result = 0; 0114 % return 0115 % end 0116 % 0117 % for j=1:length(p1.poles) 0118 % if p1.poles(j) ~= p2.poles(j) 0119 % result = 0; 0120 % return 0121 % end 0122 % end 0123 % 0124 % %% Check poles 0125 % 0126 % if length(p1.zeros) ~= length(p2.zeros) 0127 % result = 0; 0128 % return 0129 % end 0130 % 0131 % for j=1:length(p1.zeros) 0132 % if p1.zeros(j) ~= p2.zeros(j) 0133 % result = 0; 0134 % return 0135 % end 0136 % end 0137 % 0138 % %% Check version 0139 % if ~strcmp(p1.version, p2.version) 0140 % result = 0; 0141 % return 0142 % end 0143 % 0144 % %% Check created 0145 % if ~eq(p1.created, p2.created) 0146 % result = 0; 0147 % return 0148 % end 0149 %