15 views (last 30 days)

Azzi Abdelmalek
on 12 Jul 2014

Edited: Azzi Abdelmalek
on 13 Jul 2014

clear out

m1=reshape(1:30,10,3);

for k=1:3

m=data_matrix(m1(:,k));

f=num2cell(reshape([m{:}],39,[])',1);

out{1,k}=arrayfun(@(x) mean(cell2mat(f{x}'),2),1:39,'un',0);

end

out=repmat(out,10,1)

out=out(:)

Roger Stafford
on 12 Jul 2014

If your "cell" is an ordinary 'double' 30 x 39 array, A, do this:

B = [mean(A(1:10,:),1);mean(A(11:20,:),1);mean(A(21:30,:),1)];

or else this:

B = reshape(mean(reshape(A,10,[]),1),3,[]);

Either method should work.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 7 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225391

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225391

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225397

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225397

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225400

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225400

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225402

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225402

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225420

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225420

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225423

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225423

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225436

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/141587-calculate-mean-af-cell#comment_225436

Sign in to comment.