function out=cellmean(A) % USAGE: cm = cellmean(A) % Function to compute mean over cell arrays. % The output, cm, has the same size as the elements of A % Samar Khatiwala (spk@ldeo.columbia.edu) if ~iscell(A) error('Input should be a cell object') end nc=length(A) if issparse(A{1}) if ndims(A{1})>2 error('Sparse matrix must be 2-d') end m=size(A{1},1); n=size(A{1},2); out=sparse(m,n); else out=0; end for i=1:nc out=out+A{i}; end out=out/nc;