home *** CD-ROM | disk | FTP | other *** search
- 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.
-
- % C. Moler, 6-22-91.
- % Copyright (c) 1984-93 by The MathWorks, Inc.
-
- % I, J and E are matrices whose (i,j)-th element
- % is i, j and 1 respectively.
-
- J = 1:n;
- J = J(ones(n,1),:);
- I = J';
- E = ones(n,n);
- H = E./(I+J-1);
-