Home > classes > @tsdata > eq.m

eq

PURPOSE ^

EQ overloads the == operator for tsdata objects.

SYNOPSIS ^

function result = eq(c1,c2, varargin)

DESCRIPTION ^

 EQ overloads the == operator for tsdata objects.

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

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

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

 VERSION:     $Id: eq.m,v 1.7 2007/11/27 12:47:19 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 tsdata objects.
0004 %
0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0006 %
0007 % DESCRIPTION: EQ overloads the == operator for tsdata 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 tsdata objects
0020 %              exc_list - exception list
0021 %                         List of properties which are not checked.
0022 %
0023 % OUTPUTS:     If the two tsdata objects are considered equal, result == 1,
0024 %              otherwise, result == 0.
0025 %
0026 % VERSION:     $Id: eq.m,v 1.7 2007/11/27 12:47:19 ingo Exp $
0027 %
0028 % HISTORY:     29-08-2007 M Hewitson
0029 %                 Creation
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 VERSION  = '$Id: eq.m,v 1.7 2007/11/27 12:47:19 ingo Exp $';
0034 
0035 % Check if this is a call for parameters
0036 if nargin == 2
0037   if isa(c1, 'tsdata') && ischar(c2)
0038     in = char(c2);
0039     if strcmp(in, 'Params')
0040       result = plist;
0041       return
0042     elseif strcmp(in, 'Version')
0043       result = VERSION;
0044       return
0045     end
0046   end
0047 end
0048 
0049 result = 1;
0050 
0051 %% Check class
0052 if ~strcmp(class(c1), class(c2))
0053   result = 0;
0054   return
0055 end
0056 
0057 fields = fieldnames(c1);
0058 
0059 for ii = 1:length(fields)
0060   field   = fields{ii};
0061 
0062   ck_field = {field, ['tsdata/' field]};
0063 
0064   %% Check tag
0065   if ~(any(ismember(ck_field, varargin)))
0066 
0067     if isobject(c1.(field))
0068       if ~eq(c1.(field), c2.(field), varargin{:})
0069         result = 0;
0070         disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0071         return
0072       end
0073     else
0074       if ~isequalwithequalnans(c1.(field), c2.(field))
0075         result = 0;
0076         disp(sprintf('\nNOT EQUAL: %s.%s', class(c1), field));
0077         return
0078       end
0079     end
0080 
0081   end
0082 end
0083 
0084

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003