REMOVE remove a parameter from the parameter list. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: REMOVE remove a parameter from the parameter list. CALL: pl = remove(pl, 2) - removes 2nd in the list pl = remove(pl, 'key') - removes parameter called 'key' M-FILE INFO: Get information about this methods by calling >> plist.getInfo('remove') Get information about a specified set-plist by calling: >> plist.getInfo('remove', 'set') VERSION: $Id: remove.m,v 1.13 2008/09/04 15:29:31 ingo Exp $ HISTORY: 30-01-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % REMOVE remove a parameter from the parameter list. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: REMOVE remove a parameter from the parameter list. 0005 % 0006 % CALL: pl = remove(pl, 2) - removes 2nd in the list 0007 % pl = remove(pl, 'key') - removes parameter called 'key' 0008 % 0009 % M-FILE INFO: Get information about this methods by calling 0010 % >> plist.getInfo('remove') 0011 % 0012 % Get information about a specified set-plist by calling: 0013 % >> plist.getInfo('remove', 'set') 0014 % 0015 % VERSION: $Id: remove.m,v 1.13 2008/09/04 15:29:31 ingo Exp $ 0016 % 0017 % HISTORY: 30-01-2007 M Hewitson 0018 % Creation 0019 % 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 0022 function varargout = remove(varargin) 0023 0024 %%% Check if this is a call for parameters 0025 if utils.helper.isinfocall(varargin{:}) 0026 varargout{1} = getInfo(varargin{3}); 0027 return 0028 end 0029 0030 [objs, invars, rest] = utils.helper.collect_objects(varargin(:), 'plist'); 0031 0032 %%%%%%%%%% Some plausibility checks %%%%%%%%%% 0033 if numel(rest) ~= 1 0034 error('### Specify only an index OR a key-name to remove the corresponding parameter.'); 0035 end 0036 0037 val = rest{1}; 0038 0039 for ii = 1:numel(objs) 0040 pl = objs(ii); 0041 np = length(pl.params); 0042 0043 %%%%% Remove specified key %%%%% 0044 if ischar(val) 0045 idx = []; 0046 for i=1:np 0047 key = pl.params(i).key; 0048 if ~strcmpi(key, val) 0049 idx = [idx i]; 0050 end 0051 end 0052 pl.params = pl.params(idx); 0053 if length(idx) == np 0054 warning('!!! No parameter found matching key name in %d. plist', ii); 0055 end 0056 0057 %%%%% Remove specified position %%%%% 0058 elseif isnumeric(val) 0059 0060 idx = [1:val-1 val+1:np]; 0061 if max(idx) > np 0062 error('### Index exceeds number of parameters in %d. plist', ii); 0063 end 0064 pl.params = pl.params(idx); 0065 0066 %%%%% Unknown method %%%%% 0067 else 0068 error('### unknown indexing method') 0069 end 0070 0071 objs(ii) = pl; 0072 end 0073 0074 varargout{1} = objs; 0075 end 0076 0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0078 % Local Functions % 0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0080 0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0082 % 0083 % FUNCTION: getInfo 0084 % 0085 % DESCRIPTION: Get Info Object 0086 % 0087 % HISTORY: 11-07-07 M Hewitson 0088 % Creation. 0089 % 0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 0092 function ii = getInfo(varargin) 0093 if nargin == 1 && strcmpi(varargin{1}, 'None') 0094 sets = {}; 0095 pl = []; 0096 else 0097 sets = {'Default'}; 0098 pl = getDefaultPlist; 0099 end 0100 % Build info object 0101 ii = minfo(mfilename, 'plist', '', utils.const.categories.helper, '$Id: remove.m,v 1.13 2008/09/04 15:29:31 ingo Exp $', sets, pl); 0102 end 0103 0104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0105 % 0106 % FUNCTION: getDefaultPlist 0107 % 0108 % DESCRIPTION: Get Default Plist 0109 % 0110 % HISTORY: 11-07-07 M Hewitson 0111 % Creation. 0112 % 0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0114 0115 function plo = getDefaultPlist() 0116 plo = plist(); 0117 end 0118