Search code examples
arraysmatlabmatrixcell

Matlab - averaging matrices stored in cell array


Basic question for matlab. I have a cell array (2000*1), where each contains a 4*4 matrix. How can I create the average of the 2000 4*4 matrices. I thought mean( cell arrary, 3) would work, but I recieve this error:

??? Undefined function or method 'sum' for input arguments of type 'cell'.

Any ideas?


Solution

  • If you want a 4x4 average of all corresponding elements:

    >> mean( cat(3, myCell{:}), 3 )