I have a 1x24
cell array called chaining
, whose each cell contains a 119x119
matrix:
I want to find the sum of each corresponding elements of all the cells, and store them in a matrix called result
. That is, the (j,k)
th element of result
should contains the sum of the (j,k)
th elements of all the matrices in the cell array chaining
.
The code I wrote to do this is:
for j=1:size(chaining,2)
for k=1:size(chaining,2)
result(j,k) = sum(chaining{1,:}(j,k));
end
end
But this gives error because apparently MATLAB can't aggregate cell arrays for some reason (i.e., the chaining{1,:}
part).
Could anyone please show me how to go about doing this?