EQ overloads the == operator for miir objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: EQ overloads the == operator for miir 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 miir objects exc_list - exception list List of properties which are not checked. OUTPUTS: If the two miir 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 miir objects. 0004 % 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % DESCRIPTION: EQ overloads the == operator for miir 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 miir objects 0020 % exc_list - exception list 0021 % List of properties which are not checked. 0022 % 0023 % OUTPUTS: If the two miir 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, ['miir/' 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 % function result = eq(f1,f2) 0070 % 0071 % % EQ overloads the == operator for miir objects. 0072 % % 0073 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0074 % % 0075 % % DESCRIPTION: EQ overloads the == operator for miir objects. 0076 % % 0077 % % Checks that the coefficients, the sample rate, and the gain 0078 % % are the same. 0079 % % 0080 % % CALL: result = eq(t1,t2) 0081 % % 0082 % % INPUTS: f1,f2 - input miir objects 0083 % % 0084 % % OUTPUTS: If the two miir 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 they are equal 0095 % result = 1; 0096 % 0097 % %% Check coefficients 0098 % if f1.a ~= f2.a 0099 % result = 0; 0100 % return 0101 % end 0102 % if f1.b ~= f2.b 0103 % result = 0; 0104 % return 0105 % end 0106 % 0107 % %% Check gain 0108 % if f1.g ~= f2.g 0109 % result = 0; 0110 % return 0111 % end 0112 % 0113 % %% Check sample rate 0114 % if f1.fs ~= f2.fs 0115 % result = 0; 0116 % return 0117 % end