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.4 2008/01/02 17:58:51 ingo 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.4 2008/01/02 17:58:51 ingo Exp $
0012 %
0013 % HISTORY:     30-01-2007 M Hewitson
0014 %                 Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 VERSION  = '$Id: remove.m,v 1.4 2008/01/02 17:58:51 ingo Exp $';
0019 
0020 %%%%%   'Params' && 'Version' Call   %%%%%
0021 if nargin == 2
0022   if isa(pl, 'plist') && strcmp(val, 'Params')
0023     pl = plist();
0024     return
0025   elseif isa(pl, 'plist') && strcmp(val, 'Version')
0026     pl = VERSION;
0027     return
0028   end
0029 end
0030 
0031 np = nparams(pl);
0032 params = get(pl, 'params');
0033 
0034 %%%%%   Remove specified key   %%%%%
0035 if ischar(val)
0036   idx = [];
0037   for i=1:np
0038     key = get(params(i), 'key');
0039     if ~strcmpi(key, val)
0040       idx = [idx i];
0041     end
0042   end
0043   pl = plist(params(idx));
0044   if length(idx) == np
0045     warning('!!! No parameter found matching key name');
0046   end
0047   
0048 %%%%%   Remove specified position   %%%%%
0049 elseif isnumeric(val)
0050 
0051   idx = [1:val-1 val+1:np];
0052   if max(idx)>np
0053     error('### index exceeds number of parameters');
0054   end
0055   pl = plist(params(idx));
0056 
0057 %%%%%   Unknown method   %%%%%
0058 else
0059   error('### unknown indexing method')
0060 end
0061 
0062 
0063 
0064 % END

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003