diff m-toolbox/classes/@paramValue/setOptions.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/@paramValue/setOptions.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,51 @@
+% SETOPTIONS Sets the property 'options'.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: Set the property 'options'.
+%
+% CALL:        obj = obj.setOptions(options);
+%              obj = setOptions(obj, options);
+%
+% INPUTS:      obj     - single paramValue object
+%              options - new options
+%
+% REMARK:      This method checks if the options have at lease as much
+%              elements as the 'valIndex'.
+%              If 'valIndex' is equal to -1 then is it possible to set each
+%              cell to options.
+%
+% VERSION:     $Id: setOptions.m,v 1.1 2009/06/17 15:01:53 ingo Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function varargout = setOptions(varargin)
+
+  %%% Check number in inputs
+  if nargin ~= 2
+    error('### This method accepts only two inputs. The first one must be the object and the second one an integer.');
+  end
+  
+  obj = varargin{1};
+  options = varargin{2};
+  
+  %%% Check the correctness of the inputs
+  if ~isa(obj, 'paramValue') || numel(obj) ~= 1
+    error('### The first input must be a single paramValue object.');
+  end
+  if ~iscell(options)
+    error('### Please specify a cell for the options.');
+  end
+  
+  %%% Check if the 'options' have enough elements
+  if (obj.valIndex > 1) && (obj.valIndex > numel(options))
+    error('### The ''options'' must have at lease as much elements [%d] as the ''valIndex'' [%d]', numel(options), obj.valIndex);
+  end
+  
+  obj = copy(obj, nargout);
+  
+  obj.options = options;
+
+  %%% Prepare output
+  varargout{1} = obj;
+
+end