Home > classes > @ao > eq.m

eq

PURPOSE ^

EQ overloads the == operator for analysis objects.

SYNOPSIS ^

function result = eq(c1,c2, varargin)

DESCRIPTION ^

 EQ overloads the == operator for analysis objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: EQ overloads the == operator for analysis 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 analysis objects
              exc_list - exception list
                         List of properties which are not checked.

 OUTPUTS:     If the two analysis objects are considered equal, result == 1,
              otherwise, result == 0.

 VERSION:     $Id: eq.m,v 1.8 2007/10/22 13:42:36 ingo Exp $

 HISTORY:     29-08-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function result = eq(c1,c2, varargin)
0002 
0003 % EQ overloads the == operator for analysis objects.
0004 %
0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0006 %
0007 % DESCRIPTION: EQ overloads the == operator for analysis 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 analysis objects
0020 %              exc_list - exception list
0021 %                         List of properties which are not checked.
0022 %
0023 % OUTPUTS:     If the two analysis objects are considered equal, result == 1,
0024 %              otherwise, result == 0.
0025 %
0026 % VERSION:     $Id: eq.m,v 1.8 2007/10/22 13:42:36 ingo Exp $
0027 %
0028 % HISTORY:     29-08-2007 M Hewitson
0029 %                 Creation
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 %% Check length of c1 and c2
0034 if length(c1) ~= length(c2)
0035   disp(sprintf('\nNOT EQUAL: The size of the ao''s'));
0036   result = 0;
0037   return
0038 end
0039 
0040 %% Check class
0041 if ~strcmp(class(c1), class(c2))
0042   disp(sprintf('\nNOT EQUAL: The class of the ao''s'));
0043   result = 0;
0044   return
0045 end
0046 
0047 
0048 %% for each element in c1 and c2
0049 for jj = 1:numel(c1)
0050 
0051   result = 1;
0052 
0053   fields = fieldnames(c1(jj));
0054 
0055   for ii = 1:length(fields)
0056     field   = fields{ii};
0057 
0058     ck_field = {field, ['ao/' field]};
0059 
0060     % Is the field equal to history then add the name 'history'
0061     % to the exception list.
0062     if strcmp(field, 'hist')
0063       ck_field{end+1} = 'history';
0064       ck_field{end+1} = 'ao/history';
0065     end
0066 
0067     %% Check fields
0068     if ~(any(ismember(ck_field, varargin)))
0069 
0070       if isobject(c1(jj).(field))
0071         if ~eq(c1(jj).(field), c2(jj).(field), varargin{:})
0072           result = 0;
0073           disp(sprintf('\nNOT EQUAL: %s.%s', class(c1(jj)), field));
0074           return
0075         end
0076       else
0077         if ~isequalwithequalnans(c1(jj).(field), c2(jj).(field))
0078           result = 0;
0079           disp(sprintf('\nNOT EQUAL: %s.%s', class(c1(jj)), field));
0080           return
0081         end
0082       end
0083 
0084     end
0085   end
0086 
0087 end
0088 
0089 % %% Check tag
0090 % if ~(ismember('tag', varargin) || ismember('ao/tag', varargin))
0091 %   if ~(c1.tag == c2.tag)
0092 %     result = 0;
0093 %     return
0094 %   end
0095 % end
0096 %
0097 % %% Check name
0098 % if ~(ismember('name', varargin) || ismember('ao/name', varargin))
0099 %   if ~strcmp(c1.name, c2.name)
0100 %     result = 0;
0101 %     return
0102 %   end
0103 % end
0104 %
0105 % %% Check data
0106 % if ~(ismember('data', varargin) || ismember('ao/data', varargin))
0107 %   if ~strcmp(class(c1.data), class(c2.data))
0108 %     result = 0;
0109 %     return
0110 %   end
0111 %   if ~eq(c1.data, c2.data, varargin{:})
0112 %     result = 0;
0113 %     return
0114 %   end
0115 % end
0116 %
0117 % %% Check history
0118 % if ~(ismember('history', varargin) || ismember('ao/history', varargin))
0119 %   if ~eq(c1.hist, c2.hist, varargin{:})
0120 %     result = 0;
0121 %     return
0122 %   end
0123 % end
0124 %
0125 % %% Check provenance
0126 % if ~(ismember('provenance', varargin) || ismember('ao/provenance', varargin))
0127 %   if ~eq(c1.provenance, c2.provenance, varargin{:})
0128 %     result = 0;
0129 %     return
0130 %   end
0131 % end
0132 %
0133 % %% Check comment
0134 % if ~(ismember('comment', varargin) || ismember('ao/comment', varargin))
0135 %   if ~strcmp(c1.comment, c2.comment)
0136 %     result = 0;
0137 %     return
0138 %   end
0139 % end
0140 %
0141 % %% Check mfile
0142 % if ~(ismember('mfile', varargin) || ismember('ao/mfile', varargin))
0143 %   if ~isequal(c1.mfile, c2.mfile)
0144 %     result = 0;
0145 %     return
0146 %   end
0147 % end
0148 %
0149 % %% Check mfilename
0150 % if ~(ismember('mfilename', varargin) || ismember('ao/mfilename', varargin))
0151 %   if ~strcmp(c1.mfilename, c2.mfilename)
0152 %     result = 0;
0153 %     return
0154 %   end
0155 % end
0156 %
0157 % %% Check mdlfile
0158 % if ~(ismember('mdlfile', varargin) || ismember('ao/mdlfile', varargin))
0159 %   if ~strcmp(c1.mdlfile, c2.mdlfile)
0160 %     result = 0;
0161 %     return
0162 %   end
0163 % end
0164 %
0165 % %% Check mdlfilename
0166 % if ~(ismember('mdlfilename', varargin) || ismember('ao/mdlfilename', varargin))
0167 %   if ~strcmp(c1.mdlfilename, c2.mdlfilename)
0168 %     result = 0;
0169 %     return
0170 %   end
0171 % end
0172 %
0173 % %% Check version
0174 % if ~(ismember('version', varargin) || ismember('ao/version', varargin))
0175 %   if ~strcmp(c1.version, c2.version)
0176 %     result = 0;
0177 %     return
0178 %   end
0179 % end
0180 %
0181 % %% check created
0182 % if ~(ismember('created', varargin) || ismember('ao/created', varargin))
0183 %   if ~eq(c1.created, c2.created)
0184 %     result = 0;
0185 %     return
0186 %   end
0187 % end
0188 
0189 
0190 
0191

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003