diff m-toolbox/classes/@ao/setDy.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/setDy.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,112 @@
+% SETDY sets the 'dy' property of the ao.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: SETDY sets the 'dy' property of the ao.
+%
+% CALL:        objs.setDy(val);
+%              objs.setDy(val1, val2);
+%              objs.setDy(plist('dy', val));
+%              objs = objs.setDy(val);
+%
+% INPUTS:      objs: Can be a vector, matrix, list, or a mix of them.
+%              val:
+%                 0. An AO
+%                      If objs is a single object and val is an AO
+%                      then uses this function the y-values of the second
+%                      AO for 'dy'.
+%                 1. Single vector e.g. [1 2 3]
+%                      Each AO in objs get this value.
+%                 2. Single vector in a cell-array e.g. {[1 2 3]}
+%                      Each AO in objs get this value.
+%                 3. cell-array with the same number of vectors as in objs
+%                    e.g. {[6 5 4], 5, [1 2 3]} and 3 AOs in objs
+%                      Each AO in objs get its corresponding value from the
+%                      cell-array
+%
+% <a href="matlab:utils.helper.displayMethodInfo('ao', 'setDy')">Parameters Description</a>
+%
+% VERSION:     $Id: setDy.m,v 1.12 2011/09/16 05:03:06 hewitson Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function varargout = setDy(varargin)
+  
+  % Check if this is a call from a class method
+  callerIsMethod = utils.helper.callerIsMethod;
+  
+  if callerIsMethod
+    in_names = {};
+  else
+    % Collect input variable names
+    in_names = cell(size(varargin));
+    for ii = 1:nargin,in_names{ii} = inputname(ii);end
+  end
+  
+  objects = setPropertyValue(...
+    varargin{:}, ...
+    in_names, ...
+    callerIsMethod, ...
+    'dy', ...
+    @setterFcn, ...
+    nargout, ...
+    @getInfo);
+  
+  % set outputs
+  varargout = utils.helper.setoutputs(nargout, objects);
+  
+end
+
+% Setter function to set dy
+function value = setterFcn(varargin)
+  
+  if nargin < 3
+    error('Please provide a value for the ''dy'' property');
+  end
+  
+  obj   = varargin{1};
+  pl    = varargin{2};
+  value = varargin{3};
+  
+  % be careful that the returned value remains an AO!
+  if isa(value, 'ao')
+    obj.data.setDy(value.y);
+  else
+    obj.data.setDy(value);
+  end
+  
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                               Local Functions                               %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%--------------------------------------------------------------------------
+% 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.helper, '$Id: setDy.m,v 1.12 2011/09/16 05:03:06 hewitson Exp $', sets, pl);
+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({'dy', 'The vector to set'}, paramValue.EMPTY_DOUBLE);
+end
+