Home > classes > @plist > remove.m

remove

PURPOSE ^

REMOVE a parameter from the parameter list.

SYNOPSIS ^

function pl = remove(pl, val)

DESCRIPTION ^

 REMOVE a parameter from the parameter list.
 
   pl = remove(pl, 2)      - removes 2nd in the list
   pl = remove(pl, 'key')  - removes parameter called 'key'
 
 M Hewitson 30-01-07
 
 $Id: remove.html,v 1.1 2007/06/08 14:15:06 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function pl = remove(pl, val)
0002 
0003 % REMOVE a parameter from the parameter list.
0004 %
0005 %   pl = remove(pl, 2)      - removes 2nd in the list
0006 %   pl = remove(pl, 'key')  - removes parameter called 'key'
0007 %
0008 % M Hewitson 30-01-07
0009 %
0010 % $Id: remove.html,v 1.1 2007/06/08 14:15:06 hewitson Exp $
0011 %
0012 
0013 np = nparams(pl);
0014 params = get(pl, 'params');
0015 
0016 if ischar(val)
0017   idx = [];
0018   for i=1:np
0019     key = get(params(i), 'key');
0020     if ~strcmp(key, val)
0021       idx = [idx i];
0022     end    
0023   end
0024   pl = plist(params(idx));
0025   if length(idx) == np
0026     warning('!!! No parameter found matching key name');
0027   end
0028 elseif isnumeric(val)
0029   
0030   idx = [1:val-1 val+1:np];
0031   if max(idx)>np
0032     error('### index exceeds number of parameters');
0033   end
0034   pl = plist(params(idx));
0035   
0036 else
0037   error('### unknown indexing method')
0038 end
0039 
0040 
0041 
0042 % END

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003