diff m-toolbox/classes/@paramValue/setValIndex.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/setValIndex.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,48 @@
+% SETVALINDEX Sets the property 'valIndex'.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: Set the property 'valIndex'.
+%
+% CALL:        obj = obj.setValIndex(idx);
+%              obj = setValIndex(obj, idx);
+%
+% INPUTS:      obj - single paramValue object
+%              idx - new index
+%
+% REMARK:      This method checks if the index is in range of the options
+%
+% VERSION:     $Id: setValIndex.m,v 1.2 2009/06/17 15:57:57 ingo Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function varargout = setValIndex(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};
+  valIdx = 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 ~isnumeric(valIdx)
+    error('### Please specify a integer for the value index.');
+  end
+
+  %%% Check if the new index is in range of the options.
+  if valIdx > numel(obj.options)
+    error('### The value index [%d] must be inside the range of the options [%d..%d]', valIdx, (numel(obj.options)>0), max(numel(obj.options)))
+  end
+  
+  obj = copy(obj, nargout);
+  
+  obj.valIndex = valIdx;
+
+  %%% Prepare output
+  varargout{1} = obj;
+
+end