compute the means of a 3-dimensional cell array.

2 views (last 30 days)
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
Azzi Abdelmalek
Azzi Abdelmalek on 10 Oct 2012
you 20x19x20 matrices, you can't obtain 80x90*19
Ali
Ali on 10 Oct 2012
Edited: Ali on 10 Oct 2012
It's a cell array of size 20x1x19 each of its element contains 20 matrix of size 80x90
C(:,:,1) =
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
[80x90 double]
I want to compute the mean of 20 (80x90) mtrices and put the result in matrix M(80,90,1)
and so on until M(80,90,19) which will contains the mean of elements in C(:,:,19).

Sign in to comment.

Answers (1)

Andrei Bobrov
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)]);
  1 Comment
Ali
Ali on 11 Oct 2012
Hi Dear Andrei Bobrov;
your solution is working is working very well.
Can you explain me what you did ?
thank you very much.

Sign in to comment.

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!