COMBINE multiple parameter lists (plist objects) into a single plist. Duplicate parameters are given priority in the order in which they appear in the input. Usage: pl = combine(p1, p2, p3); pl = combine(p1, [p2 p3], p4) Examples: >> pl1 = plist(param('A', 1)); >> pl2 = plist(param('A', 3)); >> plo = plist(pl1, pl2) Then plo will contain a parameter 'A' with value 1. M Hewitson 28-04-07 $Id: combine.html,v 1.1 2007/06/08 14:15:06 hewitson Exp $
0001 function plo = combine(varargin) 0002 0003 % COMBINE multiple parameter lists (plist objects) into a single plist. 0004 % Duplicate parameters are given priority in the order in which they appear 0005 % in the input. 0006 % 0007 % Usage: pl = combine(p1, p2, p3); 0008 % pl = combine(p1, [p2 p3], p4) 0009 % 0010 % 0011 % Examples: 0012 % 0013 % >> pl1 = plist(param('A', 1)); 0014 % >> pl2 = plist(param('A', 3)); 0015 % >> plo = plist(pl1, pl2) 0016 % 0017 % Then plo will contain a parameter 'A' with value 1. 0018 % 0019 % M Hewitson 28-04-07 0020 % 0021 % $Id: combine.html,v 1.1 2007/06/08 14:15:06 hewitson Exp $ 0022 % 0023 0024 % get input plists 0025 % this code allows for inputs of the form: 0026 % >> pl = combine([p1 p2], p, [p3 p4], p5, p6) 0027 % or some combination of that. 0028 % 0029 pls = []; 0030 for j=1:nargin 0031 pj = varargin{j}; 0032 for k=1:length(pj) 0033 pk = pj(k); 0034 if isa(pk, 'plist') 0035 pls = [pls pk]; 0036 end 0037 end 0038 end 0039 0040 % Go through input plists and build output 0041 plo = plist(); 0042 np = length(pls); 0043 % disp(sprintf('* combining %d plists', np)); 0044 0045 for j=np:-1:1 0046 pl = pls(j); 0047 ps = pl.params; 0048 for k=1:length(ps) 0049 plo = set(plo, ps(k).key, ps(k).val); 0050 end 0051 end 0052 0053 0054 0055 0056 % END