Mercurial > hg > ltpda
comparison m-toolbox/classes/@paramValue/setValIndexAndOptions.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 % SETVALINDEXANDOPTIONS Sets the property 'valIndex' and 'options'. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Set the property 'valIndex' and 'options'. | |
5 % | |
6 % CALL: obj = obj.setValIndexAndOptions(idx, options); | |
7 % obj = setValIndexAndOptions(obj, idx, options); | |
8 % | |
9 % INPUTS: obj - single paramValue object | |
10 % idx - new index | |
11 % | |
12 % VERSION: $Id: setValIndexAndOptions.m,v 1.2 2011/02/22 15:54:09 hewitson Exp $ | |
13 % | |
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
15 | |
16 function varargout = setValIndexAndOptions(varargin) | |
17 | |
18 %%% Check number in inputs | |
19 if nargin ~= 3 | |
20 error('### This method accepts only three inputs. The first one must be the object, the second one an integer and the third the options.'); | |
21 end | |
22 | |
23 obj = varargin{1}; | |
24 valIdx = varargin{2}; | |
25 options = varargin{3}; | |
26 | |
27 %%% Check the correctness of the inputs | |
28 if ~isa(obj, 'paramValue') || numel(obj) ~= 1 | |
29 error('### The first input must be a single paramValue object.'); | |
30 end | |
31 if ~isnumeric(valIdx) | |
32 error('### Please specify a integer for the value index.'); | |
33 end | |
34 if ~iscell(options) | |
35 error('### Please specify a cell for the options.'); | |
36 end | |
37 | |
38 %%% Check if the new index is in range of the options. | |
39 if valIdx > numel(options) | |
40 error('### The value index [%d] must be inside the range of the options [%d..%d]', valIdx, min(numel(options)), max(numel(options))) | |
41 end | |
42 | |
43 if nargout == 0 | |
44 % do nothing | |
45 else | |
46 obj = copy(obj, 1); | |
47 end | |
48 | |
49 obj.valIndex = valIdx; | |
50 obj.options = options; | |
51 | |
52 %%% Prepare output | |
53 varargout{1} = obj; | |
54 | |
55 end |