0001 function outfilt = add2filt(oldfilt,newfilt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 if( ~length( newfilt ) )
0016 outfilt = oldfilt;
0017 return;
0018 end
0019
0020 if( ~length( oldfilt ) )
0021 outfilt = newfilt;
0022 return;
0023 end
0024
0025 outfilt = oldfilt;
0026
0027 old_flds = fieldnames(oldfilt);
0028 new_flds = fieldnames(newfilt);
0029
0030 for inew = 1:length(new_flds)
0031 currfldname = new_flds{inew};
0032 oldidx = strmatch(currfldname,old_flds);
0033 if isempty(oldidx)
0034 outfilt.(currfldname) = newfilt.(currfldname);
0035 else
0036
0037
0038 if isstruct(newfilt.(currfldname)) && isstruct(oldfilt.(currfldname))
0039 outfilt.(currfldname) = add2filt(oldfilt.(currfldname),newfilt.(currfldname));
0040 elseif ~isstruct(newfilt.(currfldname)) & ~isstruct(oldfilt.(currfldname))
0041
0042 new_vals = ...
0043 newfilt.(currfldname)(~ismember(newfilt.(currfldname),oldfilt.(currfldname)));
0044 old_vals = oldfilt.(currfldname);
0045 outfilt.(currfldname) = [old_vals new_vals];
0046 else
0047 fprintf('%s: Field type mismatch in field: %s\n', mfilename, currfldname);
0048 end
0049 end
0050 end