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.2 2007/07/18 13:58:45 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.2 2007/07/18 13:58:45 ingo Exp $
0012 %
0013 % HISTORY:     30-01-2007 M Hewitson
0014 %                 Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 np = nparams(pl);
0019 params = get(pl, 'params');
0020 
0021 if ischar(val)
0022   idx = [];
0023   for i=1:np
0024     key = get(params(i), 'key');
0025     if ~strcmp(key, val)
0026       idx = [idx i];
0027     end
0028   end
0029   pl = plist(params(idx));
0030   if length(idx) == np
0031     warning('!!! No parameter found matching key name');
0032   end
0033 elseif isnumeric(val)
0034 
0035   idx = [1:val-1 val+1:np];
0036   if max(idx)>np
0037     error('### index exceeds number of parameters');
0038   end
0039   pl = plist(params(idx));
0040 
0041 else
0042   error('### unknown indexing method')
0043 end
0044 
0045 
0046 
0047 % END

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003