function [m] = matmean(d)
sz = size(d);
n = prod(sz);
dims = size(sz,2);
s = d;
for i = 1:dims
s = sum(s,i);
end
m = s/n;