function xs = r8mat_standardize ( m, n, x )

%*****************************************************************************80
%
%% R8MAT_STANDARDIZE standardizes an R8MAT.
%
%  Discussion:
%
%    Each column of the output array has 0 mean and unit standard deviation.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 October 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the dimensions of the array.
%
%    real X(M,N), the array to be standardized.
%
%  Output:
%
%    real XS(M,N), the standardized array.
%
  mu = mean ( x );
  sigma = std ( x );
  xs = zeros ( m, n );

  for j = 1 : n
    if ( sigma(j) ~= 0.0 )
      xs(:,j) = ( xs(:,j) - mu(j) ) / sigma(j);
    end
  end

  return
end

