Home > m > helper > ltpda_structcat.m

ltpda_structcat

PURPOSE ^

LTPDA_STRUCTCAT concatonate structures to make one large structure.

SYNOPSIS ^

function out = ltpda_structcat(varargin)

DESCRIPTION ^

 LTPDA_STRUCTCAT concatonate structures to make one large structure.
 
 function out = ltpda_structcat(struct1, struct2, ...)
 
 'out' will contain all fields of input structures.
 
 M Hewitson 26-01-07
 
 $Id: ltpda_structcat.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out = ltpda_structcat(varargin)
0002 
0003 % LTPDA_STRUCTCAT concatonate structures to make one large structure.
0004 %
0005 % function out = ltpda_structcat(struct1, struct2, ...)
0006 %
0007 % 'out' will contain all fields of input structures.
0008 %
0009 % M Hewitson 26-01-07
0010 %
0011 % $Id: ltpda_structcat.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $
0012 %
0013 
0014 out = [];
0015 
0016 for s=1:nargin
0017   
0018   % get first input structure
0019   st = varargin{s};
0020   
0021   % check fields
0022   fields = fieldnames(st);
0023   nf     = length(fields);
0024   
0025   for f=1:nf
0026     
0027     field = char(fields(f));
0028     % check if this field already exists
0029     if isfield(out, field)
0030       warning(sprintf('!!! duplicate field ''%s'' found - skipping.', field));
0031     else
0032       % we can add this field
0033       eval(sprintf('out.%s = st.%s;', field, field));
0034     end
0035   end  
0036 end
0037 
0038 % END

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