compute the means of a 3-dimensional cell array.

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

you 20x19x20 matrices, you can't obtain 80x90*19
Ali
Ali 2012년 10월 10일
편집: Ali 2012년 10월 10일
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).

댓글을 달려면 로그인하십시오.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 10월 10일
편집: Andrei Bobrov 2012년 10월 10일

2 개 추천

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

Ali
Ali 2012년 10월 11일
Hi Dear Andrei Bobrov;
your solution is working is working very well.
Can you explain me what you did ?
thank you very much.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

Ali
2012년 10월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by