Mercurial > hg > ltpda
diff m-toolbox/classes/@ao/le.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/le.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,85 @@ +% LE overloads <= operator for analysis objects. Compare the y-axis values. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: LE 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', 'le')">Parameters Description</a> +% +% VERSION: $Id: le.m,v 1.24 2011/04/08 08:56:12 hewitson Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = le(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: le.m,v 1.24 2011/04/08 08:56:12 hewitson Exp $', sets, pl); + ii.setModifier(false); + 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 plo = buildplist() + plo = plist.EMPTY_PLIST; +end +