MATLAB: How to calculate a mean of an cell array

cell arraysmatrix

  • i have a 3*6 matrix
m=[pc oc rc;
yc centroid ic;
ec uc hc]
  • where each value (pc, or…) define x,y coordonates of a pixel, then i converted this matrix to an cell array with :
c=mat2cell(m,ones(1,size(m,1)),2*ones(1,size(m,2)/2))
  • here i want to calcule a mean of this cell array:*
A=[mean(reshape(cell2mat(c), [2, 3, 3]), 3)]
  • but the result is not that one i want :(, i want to know where the problem is and how can i correct it

Best Answer

Why are you using cell arrays? Why not just take the mean of m before doing any cell array stuff? Make m a 3D array instead of a cell array if you have multiple copies of m, then take the mean.
mMean = mean(m, 3)