home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SPECMAT.DI$ / HILB.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  638 b   |  23 lines

  1. function H = hilb(n)
  2. %HILB    Hilbert matrix.
  3. %    HILB(N) is the N by N matrix with elements 1/(i+j-1),
  4. %    which is a famous example of a badly conditioned matrix.
  5. %    See INVHILB for the exact inverse.
  6. %
  7. %    This is also a good example of efficient MATLAB programming
  8. %    style where conventional FOR or DO loops are replaced by
  9. %    vectorized statements.  This approach is faster, but uses
  10. %    more storage.
  11.  
  12. %    C. Moler, 6-22-91.
  13. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  14.  
  15. %   I, J and E are matrices whose (i,j)-th element
  16. %   is i, j and 1 respectively.
  17.  
  18. J = 1:n;
  19. J = J(ones(n,1),:);
  20. I = J';
  21. E = ones(n,n);
  22. H = E./(I+J-1);
  23.