


COMBINE multiple parameter lists (plist objects) into a single plist.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: 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.
CALL: 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.
VERSION: $Id: combine.m,v 1.4 2007/07/18 13:58:45 ingo Exp $
HISTORY: 28-04-2007 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function plo = combine(varargin) 0002 % COMBINE multiple parameter lists (plist objects) into a single plist. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: COMBINE multiple parameter lists (plist objects) into a single 0007 % plist. Duplicate parameters are given priority in the order 0008 % in which they appear in the input. 0009 % 0010 % CALL: pl = combine(p1, p2, p3); 0011 % pl = combine(p1, [p2 p3], p4) 0012 % 0013 % EXAMPLES: >> 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 % VERSION: $Id: combine.m,v 1.4 2007/07/18 13:58:45 ingo Exp $ 0020 % 0021 % HISTORY: 28-04-2007 M Hewitson 0022 % Creation 0023 % 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 0026 0027 % get input plists 0028 % this code allows for inputs of the form: 0029 % >> pl = combine([p1 p2], p, [p3 p4], p5, p6) 0030 % or some combination of that. 0031 % 0032 pls = []; 0033 for j=1:nargin 0034 pj = varargin{j}; 0035 for k=1:length(pj) 0036 pk = pj(k); 0037 if isa(pk, 'plist') 0038 pls = [pls pk]; 0039 end 0040 end 0041 end 0042 0043 % Go through input plists and build output 0044 plo = plist(); 0045 np = length(pls); 0046 % disp(sprintf('* combining %d plists', np)); 0047 0048 for j=np:-1:1 0049 pl = pls(j); 0050 ps = pl.params; 0051 for k=1:length(ps) 0052 plo = set(plo, ps(k).key, ps(k).val); 0053 end 0054 end 0055 0056 0057 0058 0059 % END