comparison m-toolbox/classes/@param/setDefaultIndex.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 % SETDEFAULTINDEX Sets the index which points to the default value to the input.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETDEFAULTINDEX Sets the index which points to the default
5 % value to the input.
6 %
7 % CALL: obj = obj.setDefaultIndex(index);
8 %
9 % INPUTS: obj - A single param object
10 % index - An index to the default option which should to be set.
11 %
12 % VERSION: $Id: setDefaultIndex.m,v 1.2 2011/02/22 15:51:44 hewitson Exp $
13 %
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15
16 function p = setDefaultIndex(p, index)
17
18 % Check input
19 if numel(p) ~= 1
20 error('### This method works only with one input parameter object.');
21 end
22 if ~isnumeric(index) && numel(index) ~= 1
23 error('### This method works only with one input index.');
24 end
25
26 % Make a copy if the user doesn't use the modifier command
27 p = copy(p, nargout);
28
29 if isa(p.val, 'paramValue')
30 if numel(p.val.options) >= index
31 p.val.setValIndex(index);
32 else
33 error('### The number of param-options [%d] is for the new index [%d] not enough.', numel(p.val.options), index);
34 end
35 else
36 warning('!!! This parameter [%s] has no options', p.key);
37 end
38
39 end
40