Home > classes > @plist > remove.m

remove

PURPOSE ^

REMOVE remove a parameter from the parameter list.

SYNOPSIS ^

function pl = remove(pl, val)

DESCRIPTION ^

 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'

 VERSION:     $Id: remove.m,v 1.5 2008/02/14 08:29:09 mauro Exp $

 HISTORY:     30-01-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function pl = remove(pl, val)
0002 % REMOVE remove a parameter from the parameter list.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: REMOVE remove a parameter from the parameter list.
0007 %
0008 % CALL:        pl = remove(pl, 2)      - removes 2nd in the list
0009 %              pl = remove(pl, 'key')  - removes parameter called 'key'
0010 %
0011 % VERSION:     $Id: remove.m,v 1.5 2008/02/14 08:29:09 mauro Exp $
0012 %
0013 % HISTORY:     30-01-2007 M Hewitson
0014 %                 Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 VERSION  = '$Id: remove.m,v 1.5 2008/02/14 08:29:09 mauro Exp $';
0019 CATEGORY = 'Helper';
0020 
0021 %%%%%   'Params' && 'Version' Call   %%%%%
0022 if nargin == 2
0023   if isa(pl, 'plist') && strcmp(val, 'Params')
0024     pl = plist();
0025     return
0026   elseif isa(pl, 'plist') && strcmp(val, 'Version')
0027     pl = VERSION;
0028     return
0029   elseif isa(pl, 'plist') && strcmp(val, 'Category')
0030     pl = CATEGORY;
0031     return
0032   end
0033 end
0034 
0035 np = nparams(pl);
0036 params = get(pl, 'params');
0037 
0038 %%%%%   Remove specified key   %%%%%
0039 if ischar(val)
0040   idx = [];
0041   for i=1:np
0042     key = get(params(i), 'key');
0043     if ~strcmpi(key, val)
0044       idx = [idx i];
0045     end
0046   end
0047   pl = plist(params(idx));
0048   if length(idx) == np
0049     warning('!!! No parameter found matching key name');
0050   end
0051   
0052 %%%%%   Remove specified position   %%%%%
0053 elseif isnumeric(val)
0054 
0055   idx = [1:val-1 val+1:np];
0056   if max(idx)>np
0057     error('### index exceeds number of parameters');
0058   end
0059   pl = plist(params(idx));
0060 
0061 %%%%%   Unknown method   %%%%%
0062 else
0063   error('### unknown indexing method')
0064 end
0065 
0066 
0067 
0068 % END

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003