Mercurial > hg > ltpda
diff m-toolbox/classes/@smodel/minus.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/@smodel/minus.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,82 @@ +% MINUS implements subtraction operator for smodel objects. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: MINUS implements subtraction operator for two smodel objects. +% +% CALL: obj = obj1-obj2 +% obj = minus(obj1,obj2); +% +% <a href="matlab:utils.helper.displayMethodInfo('smodel', 'minus')">Parameters Description</a> +% +% VERSION: $Id: minus.m,v 1.10 2011/05/10 20:35:29 mauro Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = minus(varargin) + + callerIsMethod = utils.helper.callerIsMethod; + + % Check if this is a call for parameters + if utils.helper.isinfocall(varargin{:}) + varargout{1} = getInfo(varargin{3}); + return + end + + % Settings + op = 'minus'; + opname = 'subtraction'; + opsym = '-'; + + if callerIsMethod + pl = []; + infoObj = []; + else + pl = getDefaultPlist(); + infoObj = getInfo('None'); + end + varNames = cell(size(varargin)); + for ii = 1:nargin,varNames{ii} = inputname(ii);end + + if nargout == 0 + error('### A %s operator can not be used as a modifier.', opname); + end + + mdl = smodel.elementOp(callerIsMethod, op, opname, opsym, infoObj, pl, varargin(:), varNames); + + % Set output + varargout = utils.helper.setoutputs(nargout, mdl); + +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, 'smodel', 'ltpda', utils.const.categories.aop, '$Id: minus.m,v 1.10 2011/05/10 20:35:29 mauro Exp $', sets, pl); + ii.setArgsmin(2); + ii.setModifier(false); +end + +%-------------------------------------------------------------------------- +% Get Default Plist +%-------------------------------------------------------------------------- +function plout = getDefaultPlist() + persistent pl; + if ~exist('pl', 'var') || isempty(pl) + pl = buildplist(); + end + plout = pl; +end + +function pl = buildplist() + pl = plist.EMPTY_PLIST; +end