SETVAL Set the property 'val'. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Set the property 'val'. CALL: obj = obj.setVal('new val'); obj = obj.setVal(plist('val', 'new val')); obj = setVal(obj, 'new val'); INPUTS: obj - can be a vector, matrix, list, or a mix of them. pl - to set the val with a plist specify only one plist with only one key-word 'val'. M-FILE INFO: Get information about this methods by calling >> param.getInfo('setVal') Get information about a specified set-plist by calling: >> param.getInfo('setVal', 'set') VERSION: $Id: setVal.m,v 1.6 2008/09/04 15:29:31 ingo Exp $ HISTORY: 27-05-2008 Diepholz Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % SETVAL Set the property 'val'. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: Set the property 'val'. 0005 % 0006 % CALL: obj = obj.setVal('new val'); 0007 % obj = obj.setVal(plist('val', 'new val')); 0008 % obj = setVal(obj, 'new val'); 0009 % 0010 % INPUTS: obj - can be a vector, matrix, list, or a mix of them. 0011 % pl - to set the val with a plist specify only one plist with 0012 % only one key-word 'val'. 0013 % 0014 % M-FILE INFO: Get information about this methods by calling 0015 % >> param.getInfo('setVal') 0016 % 0017 % Get information about a specified set-plist by calling: 0018 % >> param.getInfo('setVal', 'set') 0019 % 0020 % VERSION: $Id: setVal.m,v 1.6 2008/09/04 15:29:31 ingo Exp $ 0021 % 0022 % HISTORY: 27-05-2008 Diepholz 0023 % Creation 0024 % 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 0027 function varargout = setVal(varargin) 0028 0029 %%% Check if this is a call for parameters 0030 if utils.helper.isinfocall(varargin{:}) 0031 varargout{1} = getInfo(varargin{3}); 0032 return 0033 end 0034 0035 %%% Internal call: Only one object + don't look for a plist 0036 if strcmp(varargin{end}, 'internal') 0037 0038 %%% decide whether we modify the first plist, or create a new one. 0039 varargin{1} = copy(varargin{1}, nargout); 0040 0041 varargin{1}.val = varargin{2}; 0042 varargout{1} = varargin{1}; 0043 return 0044 end 0045 0046 [objs, invars, rest] = utils.helper.collect_objects(varargin(:), 'param'); 0047 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); 0048 0049 vals = rest; 0050 0051 if length(vals) ~=1 0052 0053 if length(pls) == 1 0054 vals = {}; 0055 if nparams(pls) == 1 && isparam(pls, 'val') 0056 0057 %%% If the plist contains only one parameter with the key-word 'val' 0058 %%% then set 'val' to the value in the plist 0059 vals{1} = find(pls, 'val'); 0060 0061 else 0062 vals{1} = pls; 0063 end 0064 elseif length(pls) > 1 0065 error('### To set the ''val'' please specify only one plist') 0066 else 0067 error('### Please specify [only one] value.') 0068 end 0069 end 0070 0071 %%% Set the Val 0072 for ii = 1:numel(objs) 0073 0074 %%% decide whether we modify the first plist, or create a new one. 0075 objs(ii) = copy(objs(ii), nargout); 0076 0077 objs(ii).val = vals{1}; 0078 end 0079 0080 %%% Prepare output 0081 varargout{1} = objs; 0082 end 0083 0084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0085 % 0086 % FUNCTION: getInfo 0087 % 0088 % DESCRIPTION: Get Info Object 0089 % 0090 % HISTORY: 11-07-07 M Hewitson 0091 % Creation. 0092 % 0093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0094 0095 function ii = getInfo(varargin) 0096 if nargin == 1 && strcmpi(varargin{1}, 'None') 0097 sets = {}; 0098 pl = []; 0099 else 0100 sets = {'Default'}; 0101 pl = getDefaultPlist; 0102 end 0103 % Build info object 0104 ii = minfo(mfilename, 'param', '', utils.const.categories.internal, '$Id: setVal.m,v 1.6 2008/09/04 15:29:31 ingo Exp $', sets, pl); 0105 end 0106 0107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0108 % 0109 % FUNCTION: getDefaultPlist 0110 % 0111 % DESCRIPTION: Get Default Plist 0112 % 0113 % HISTORY: 11-07-07 M Hewitson 0114 % Creation. 0115 % 0116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0117 0118 function plo = getDefaultPlist() 0119 plo = plist('val', ''); 0120 end 0121