diff m-toolbox/classes/@ao/ge.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@ao/ge.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,83 @@
+% GE overloads >= operator for analysis objects. Compare the y-axis values.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: GE overloads >= operator for analysis objects.
+%              Compare the y-axis values.
+%
+% CALL:        a = b>=c;
+%
+% INPUTS:      b - Analysis object
+%              c - Analysis object Or a number
+%
+% OUTPUTS:     a - vector of logical values from the comparison.
+%
+% <a href="matlab:utils.helper.displayMethodInfo('ao', 'ge')">Parameters Description</a>
+%
+% VERSION:     $Id: ge.m,v 1.26 2011/04/08 08:56:17 hewitson Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function varargout = ge(varargin)
+
+  % Check if this is a call for parameters
+  if utils.helper.isinfocall(varargin{:})
+    varargout{1} = getInfo(varargin{3});
+    return
+  end
+  
+  % Collect input variable names
+  in_names = cell(size(varargin));
+  for ii = 1:nargin,in_names{ii} = inputname(ii);end
+  
+  [pl, plvars, rest] = utils.helper.collect_objects(varargin(:), 'plist', in_names);
+
+  if ~(numel(rest) == 2 && ...
+      ((isa(rest{1}, 'ao') && isa(rest{2}, 'ao')) || ...
+      (isa(rest{1}, 'ao') && isnumeric(rest{2}))))
+    error('### comparisons only between analysis objects and/or numbers.')
+  end
+
+  x = rest{1}.data.getY;
+
+  if isa(rest{2}, 'ao')
+    y = rest{2}.data.getY;
+  else
+    y = rest{2}*ones(size(x));
+  end
+
+  a = x >= y;
+
+  % Set output
+  varargout{1} = a;
+end
+%--------------------------------------------------------------------------
+% Get Info Object
+%--------------------------------------------------------------------------
+function ii = getInfo(varargin)
+  if nargin == 1 && strcmpi(varargin{1}, 'None')
+    sets = {};
+    pl   = [];
+  else
+    sets = {'Default'};
+    pl   = getDefaultPlist;
+  end
+  % Build info object
+  ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.relop, '$Id: ge.m,v 1.26 2011/04/08 08:56:17 hewitson Exp $', sets, pl);
+  ii.setArgsmin(2);
+end
+%--------------------------------------------------------------------------
+% Get Default Plist
+%--------------------------------------------------------------------------
+
+function plout = getDefaultPlist()
+  persistent pl;  
+  if exist('pl', 'var')==0 || isempty(pl)
+    pl = buildplist();
+  end
+  plout = pl;  
+end
+
+function pl = buildplist()
+  pl = plist.EMPTY_PLIST;
+end
+