function xs = r8mat_scale_01 ( m, n, x )

%*****************************************************************************80
%
%% R8MAT_SCALE_01 scales the columns of an R8MAT to [0,1].
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    07 October 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, N, the number of entries in the vector.
%
%    Input, real X(M,N), the array to be scaled.
%
%    Output, real XS(M,N), the scaled array.
%
  [ m, n ] = size ( x );
  xmin = min ( x );
  xmax = max ( x );
  xs = zeros ( m, n );
  for j = 1 : n
    if ( 0.0 < xmax(j) - xmin(j) )
      xs(1:m,j) = ( x(1:m,j) - xmin(j) ) / ( xmax(j) - xmin(j) );
    else
      xs(1:m,j) = 0.5;
    end
  end

  return
end

