MATLAB: Adding cell array entries

adding cell array

Suppose you have a 162*24 cell array called CC and each cell array entry consist of a matrix.
How would you add CC{1,1}+CC{2,1}+CC {3,1}…..CC{162,1}
and then to the same for the remaining 23 columns.
I dont need the sum but all matrices within each cell entry have to be added.
Thanks

Best Answer

nd = ndims(CC{1,1});
sol = sum(cat(ndims+1, CC{:,1}),ndims+1);
There are also approaches using the more obscure fold() operation.