Robochameleon
v1.0
|
Concatenate or merge structures with different fieldnames. More...
Go to the source code of this file.
Functions | |
function | catstruct (in varargin) |
Concatenate or merge structures with different fieldnames. More... | |
Concatenate or merge structures with different fieldnames.
X = CATSTRUCT(S1,S2,S3,...) merges the structures S1, S2, S3 ... into one new structure X. X contains all fields present in the various structures. An example:
If a fieldname is not unique among structures (i.e., a fieldname is present in more than one structure), only the value from the last structure with this field is used. In this case, the fields are alphabetically sorted. A warning is issued as well. An axample:
The inputs can be array of structures. All structures should have the same size. An example:
The last input can be the string 'sorted'. In this case, CATSTRUCT(S1,S2, ..., 'sorted') will sort the fieldnames alphabetically. To sort the fieldnames of a structure A, you could use CATSTRUCT(A,'sorted') but I recommend ORDERFIELDS for doing that.
When there is nothing to concatenate, the result will be an empty struct (0x0 struct array with no fields).
Notes
for Matlab R13 and up, tested in R2011a and up
Definition in file catstruct.m.
function catstruct | ( | in | varargin | ) |
Concatenate or merge structures with different fieldnames.
S1,S2,etc | Structures to be concatenated |
A | Combined structure |