function H = hilb(n)
%HILB   Hilbert matrix.
%   HILB(N) is the N by N matrix with elements 1/(i+j-1),
%   which is a famous example of a badly conditioned matrix.
%   See INVHILB for the exact inverse.
%
%   This is also a good example of efficient MATLAB programming
%   style where conventional FOR or DO loops are replaced by
%   vectorized statements.  This approach is faster, but uses
%   more storage.
%
%   See also INVHILB.

%   C. Moler, 6-22-91.
%   Copyright 1984-2004 The MathWorks, Inc.
%   $Revision: 5.10.4.3 $  $Date: 2004/07/05 17:01:18 $

%   I, J and E are matrices whose (i,j)-th element
%   is i, j and 1 respectively.

J = 1:double(n);
J = J(ones(n,1),:);
I = J';
E = ones(n,n,'double');
H = E./(I+J-1);
