How to concatenate multi-layered structs?

5 views (last 30 days)
Daniel Abraham
Daniel Abraham on 17 Jul 2021
Commented: Walter Roberson on 23 Jul 2021
Hello everyone, I have a 1x1083 struct (Scombined) which has about 1,083 1x20 cells in them. These cells also contain 20 different structs within them and here is a preview of how it is structured. I want to concatenate all columns of all the structs in the cells, cells Scombined(1).Data to Scombined(1083) to form one column respectively and then after concatentate all 1,083 cells by rows to form just one cell under the main struct Scombined. I am new to MATLAB so I am not sure of how to do this. It's really complicated for me.
I'd very much appreciate an answer or ideas on how to go about it, Thanks in advance !
  1 Comment
Walter Roberson
Walter Roberson on 23 Jul 2021
I am not clear about the organization of your data.
1x1083 struct (Scombined)
Okay, Scombined is a 1 x 1083 struct, and we can see that you have shown us part of Scombined(1)
But you say the 1 x 1083 struct "has about 1,083 1x20 cells in them". But struct do not contain cells directly: struct contain fields. Do you mean that Scombined(K) is a struct that has 1083 different fields, one of which happened to be named Data ? Or is the information about 1,083 1x20 cells redundent, and Scombined is a 1 x 1083 struct that has a single field named Data that is a 1 x 20 cell array? And each of the cell array entries contains a 1 x 1 struct (as shown in the image) ? But it does not make sense to talk about concatenating all columns when each entry is a 1 x 1 struct... not unless you want to get down lower to fields of structs...
I am confused about how many entries there are in total and what is to be concatenated.
If you were to write an index expression to get to the innermost object, what would that expression look like?

Sign in to comment.

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!