Concatenate rows within a 3D cell array
    8 views (last 30 days)
  
       Show older comments
    
I originally had a 3D structure with 6 fields. 
structure(1:17,1:10,1:16).A
structure(1:17,1:10,1:16).B
structure(1:17,1:10,1:16).C
structure(1:17,1:10,1:16).D
structure(1:17,1:10,1:16).E
structure(1:17,1:10,1:16).F
For each location, I would like to concatente A,C&E so I end up with a 3D (17x10x16) cell array with A,C&E in horizontal cat for each location.
For example, structure(17,10,16).A is a 1 x10 cell array 
[2×149 double]    [2×146 double]    [2×142 double]    [2×144 double]    [2×147 double] [2×147 double]    [2×150 double]    [2×145 double]    [2×141 double]    [2×145 double]
 structure(17,10,16).C is a 1 x10 cell array 
[2×479 double]    [2×482 double]    [2×487 double]    [2×486 double]    [2×475 double] [2×489 double]    [2×491 double]    [2×482 double]    [2×474 double]    [2×466 double]
structure(17,10,16).E is a 1 x10 cell array 
[2×454 double]    [2×461 double]    [2×500 double]    [2×464 double]    [2×463 double] [2×475 double]    [2×499 double]    [2×468 double]    [2×483 double]    [2×497 double]
I started by:
cat_1=arrayfun(@(x) [x.A;x.C;x.E],structure,'uni', false)
It gives a 17x10x16 cell array with a {3x10 cell} in each location.
For example , cat_1{17,10,16} is 
[2×149  double]  [2×146  double]  [2×142  double]  [2×144  double]  [2×147  double]  [2×147  double]  [2×150  double]  [2×145  double]  [2×141  double]  [2×145  double] 
[2×479  double]  [2×482  double]  [2×487  double]  [2×486  double]  [2×475  double]  [2×489  double]  [2×491  double]  [2×482  double]  [2×474  double]  [2×466  double] 
[2×454  double]  [2×461  double]  [2×500  double]  [2×464  double]  [2×463  double]  [2×475  double]  [2×499  double]  [2×468  double]  [2×483  double]  [2×497  double] 
Now, I am stuck on concatenating each column so I endup with a {1x10 cell} in each locacion.
For example, cat_2{17,10,16} to be
[2x1082  double]  [2x1089  double]  [2x1129  double]  [2x1094  double]  [2x1085  double]  [2x1111  double]  [2x1140  double]  [2x1095  double]  [2x1098  double]  [2x1108  double] 
I have tried several combiantions of cellfun and arrayfun with horcat, cat in different dimensions but I do not get the above organization for each location of the 3D cell array.
Thank you,
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
				Find more on Creating and Concatenating Matrices 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!
