How to accumulate different structs, with same fields beneath one another
Show older comments
I have a struct, which is similar format to the one below. I have 128 different people with the data in the same format, like the one below.
All I'm trying to do, is write a loop which will simply read in each participants struct (in the exact same format as below), and stack all of the results of the participants in one cotinuous vector for each specific field.
So eventually we would have one long field containing all of the field1 variables for all participants
One long field containing all of the field2 variables for all participants in the same struct...
All I can get at the moment, is the loop to replace the data existing in the struct, rather than add it underneath the previous participant's..
Please can someone help me?
Thanks
Cam
s = struct(field1,value1,field2,value2,field3,value3,field4,value4, field5,value5)
field1 = 'f1'; value1 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'};
field2 = 'f2'; value2 = {1,2,3,4,5,6,7,8,9};
field3 = 'f3'; value3 = {13,32,3.2,42,5,26,7,38,9};
field4 = 'f4'; value4 = {1,2,3,34,35,6,7,83,9};
field5 = 'f5'; value5 = {1,4,11,45,5,6,17,28,79};
Accepted Answer
More Answers (0)
Categories
Find more on Structures 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!