How to add (combine) together two structures with the same fields?
Show older comments
Dear All,
I have two structures A and B with the same fields. How can I combine them together to form a new structure?
For example, A = struct('field1', array1, 'field2', array2); B = struct('field1', array3, 'field2', array4). A and B have the same fields 'field1' and 'field2'. I want to combine A and B together to obtain structure C = struct('field1', [array1; array3], 'field2', [array2; array4]). array1 and array3 have the same number of columns, and array2 and array4 have the same number of columns.
Thanks.
Benson
2 Comments
Geoff Hayes
on 11 Jun 2021
Benson - what should the new structure look like? If A and B have the same fields, then does that mean that the combined A and B have array fields? Please illustrate with a small example.
Benson Gou
on 11 Jun 2021
Accepted Answer
More Answers (0)
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!