Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@prog/structcat.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function out = structcat(varargin) | |
2 % STRUCTCAT concatonate structures to make one large structure. | |
3 % | |
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
5 % | |
6 % DESCRIPTION: STRUCTCAT concatonate structures to make one large | |
7 % structure. | |
8 % | |
9 % CALL: out = structcat(struct1, struct2, ...) | |
10 % | |
11 % INPUTS: struct1 - a structure | |
12 % struct2 - a structure | |
13 % | |
14 % OUTPUTS: out - structure with all fields of input structures. | |
15 % | |
16 % VERSION: $Id: structcat.m,v 1.1 2008/06/18 13:35:11 hewitson Exp $ | |
17 % | |
18 % HISTORY: 26-01-2007 M Hewitson | |
19 % Creation | |
20 % | |
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
22 | |
23 out = []; | |
24 | |
25 for s=1:nargin | |
26 | |
27 % get first input structure | |
28 st = varargin{s}; | |
29 | |
30 % check fields | |
31 fields = fieldnames(st); | |
32 nf = length(fields); | |
33 | |
34 for f=1:nf | |
35 | |
36 field = fields{f}; | |
37 % check if this field already exists | |
38 if isfield(out, field) | |
39 warning(sprintf('!!! duplicate field ''%s'' found - skipping.', field)); | |
40 else | |
41 % we can add this field | |
42 out.(field) = st.(field); | |
43 end | |
44 end | |
45 end | |
46 | |
47 % END |