compute the means of a 3-dimensional cell array.
2 views (last 30 days)
Show older comments
Hi, I have a cell array C of size < 20x1x19 >, each one the 19 elements contains a set of 20 matrices of size (80x90), How can I want to compute the mean of each 20 matrix and store the result in a matrix M so that in the end I will have a Matrix of size 80x90x19 containing the means of the cell array matrices.
for example:
M(:,:,1) will have the mean of elements in C(:,:,1);
M(:,:,2) will have the mean of elements in C(:,:,2)
and so on. Thank you very much.
2 Comments
Answers (1)
Andrei Bobrov
on 10 Oct 2012
Edited: Andrei Bobrov
on 10 Oct 2012
Here C - cell array of 20x1x19
C{1} - a double array of 80 x 90
sC = size(C);
out0 = mean(cell2mat(reshape(C,1,1,sC(1),[])),3);
out = reshape(out0,[size(C{1}),sC(3)]);
See Also
Categories
Find more on Data Types 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!