How to concatenate multi-layered structs?

조회 수: 6 (최근 30일)
Daniel Abraham
Daniel Abraham 2021년 7월 17일
댓글: Walter Roberson 2021년 7월 23일
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
Walter Roberson
Walter Roberson 2021년 7월 23일
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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by