% The M-script to calculate the mean of a 2-dimensional X2 matrix.
% X2 must exist before running this M-script
%
% Author: Borgo, Soranzo, Grassi 2010

[Nrows,Ncols]=size(X2)
meanX = 0;

for indr=1:Nrows
    for indc=1:Ncols
        meanX=meanX+X2(indr,indc);
    end
end
Nelem=Nrows*Ncols;
meanX=meanX/Nelem;

disp(sprintf('the X mean is %2.2f',meanX));