LTPDA_STRUCTCAT concatonate structures to make one large structure. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: LTPDA_STRUCTCAT concatonate structures to make one large structure. CALL: out = ltpda_structcat(struct1, struct2, ...) INPUTS: struct1 - a structure struct2 - a structure OUTPUTS: out - structure with all fields of input structures. VERSION: $Id: ltpda_structcat.m,v 1.5 2007/07/13 12:17:39 ingo Exp $ HISTORY: 26-01-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function out = ltpda_structcat(varargin) 0002 % LTPDA_STRUCTCAT concatonate structures to make one large structure. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: LTPDA_STRUCTCAT concatonate structures to make one large 0007 % structure. 0008 % 0009 % CALL: out = ltpda_structcat(struct1, struct2, ...) 0010 % 0011 % INPUTS: struct1 - a structure 0012 % struct2 - a structure 0013 % 0014 % OUTPUTS: out - structure with all fields of input structures. 0015 % 0016 % VERSION: $Id: ltpda_structcat.m,v 1.5 2007/07/13 12:17:39 ingo Exp $ 0017 % 0018 % HISTORY: 26-01-2007 M Hewitson 0019 % Creation 0020 % 0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0022 0023 out = []; 0024 0025 for s=1:nargin 0026 0027 % get first input structure 0028 st = varargin{s}; 0029 0030 % check fields 0031 fields = fieldnames(st); 0032 nf = length(fields); 0033 0034 for f=1:nf 0035 0036 field = char(fields(f)); 0037 % check if this field already exists 0038 if isfield(out, field) 0039 warning(sprintf('!!! duplicate field ''%s'' found - skipping.', field)); 0040 else 0041 % we can add this field 0042 eval(sprintf('out.%s = st.%s;', field, field)); 0043 end 0044 end 0045 end 0046 0047 % END