comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % SETVALINDEX Sets the property 'valIndex'.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: Set the property 'valIndex'.
5 %
6 % CALL: obj = obj.setValIndex(idx);
7 % obj = setValIndex(obj, idx);
8 %
9 % INPUTS: obj - single paramValue object
10 % idx - new index
11 %
12 % REMARK: This method checks if the index is in range of the options
13 %
14 % VERSION: $Id: setValIndex.m,v 1.2 2009/06/17 15:57:57 ingo Exp $
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18 function varargout = setValIndex(varargin)
19
20 %%% Check number in inputs
21 if nargin ~= 2
22 error('### This method accepts only two inputs. The first one must be the object and the second one an integer.');
23 end
24
25 obj = varargin{1};
26 valIdx = varargin{2};
27
28 %%% Check the correctness of the inputs
29 if ~isa(obj, 'paramValue') || numel(obj) ~= 1
30 error('### The first input must be a single paramValue object.');
31 end
32 if ~isnumeric(valIdx)
33 error('### Please specify a integer for the value index.');
34 end
35
36 %%% Check if the new index is in range of the options.
37 if valIdx > numel(obj.options)
38 error('### The value index [%d] must be inside the range of the options [%d..%d]', valIdx, (numel(obj.options)>0), max(numel(obj.options)))
39 end
40
41 obj = copy(obj, nargout);
42
43 obj.valIndex = valIdx;
44
45 %%% Prepare output
46 varargout{1} = obj;
47
48 end