Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@paramValue/setValIndexAndOptions.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,55 @@ +% SETVALINDEXANDOPTIONS Sets the property 'valIndex' and 'options'. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: Set the property 'valIndex' and 'options'. +% +% CALL: obj = obj.setValIndexAndOptions(idx, options); +% obj = setValIndexAndOptions(obj, idx, options); +% +% INPUTS: obj - single paramValue object +% idx - new index +% +% VERSION: $Id: setValIndexAndOptions.m,v 1.2 2011/02/22 15:54:09 hewitson Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = setValIndexAndOptions(varargin) + + %%% Check number in inputs + if nargin ~= 3 + error('### This method accepts only three inputs. The first one must be the object, the second one an integer and the third the options.'); + end + + obj = varargin{1}; + valIdx = varargin{2}; + options = varargin{3}; + + %%% 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 + if ~iscell(options) + error('### Please specify a cell for the options.'); + end + + %%% Check if the new index is in range of the options. + if valIdx > numel(options) + error('### The value index [%d] must be inside the range of the options [%d..%d]', valIdx, min(numel(options)), max(numel(options))) + end + + if nargout == 0 + % do nothing + else + obj = copy(obj, 1); + end + + obj.valIndex = valIdx; + obj.options = options; + + %%% Prepare output + varargout{1} = obj; + +end