First step: change your algorithm to create just one variable. Options are a cell array of these cell arrays or concatenating the content of the cells in an extra dimension. Once that's done it's almost trivial to calculate the mean:
A = {A1, A2, ...
meanA = cellfun(@(varargin) mean(cat(ndims(varargin{1})+1, varargin{:}), ndims(varargin{1})+1) , A{:}, 'UniformOutput', false)
The complication here is that I don't know the dimensionality of the matrices you want to average. All the cellfun does is concatenate them all in a higher dimension and take the mean in that dimension.
The result of the concatenation without the mean calculation would be the other way to keep your matrices together
A = {A1, A2, ...
A = cellfun(@(varargin) cat(ndims(varargin{1})+1, varargin{:}), A{:}, 'UniformOutput', false)
Best Answer