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

  1. function Q = null(A) 
  2. %NULL    Null space.
  3. %    Q = null(A) is an orthonormal basis for the null space of A.
  4. %    Q'*Q = I, A*Q = 0, and the number of columns of Q is the
  5. %    nullity of A.
  6. %
  7. %    See also QR, ORTH.
  8.  
  9. %    C.B. Moler 1-1-86
  10. %    Revised 4-1-87, 7-10-90 CBM
  11. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  12.  
  13. % QR decomposition of the transpose.
  14. [Q,R,E]=qr(A');
  15. % Determine effective nullity
  16. tol = eps*norm(A,'fro');
  17. [m,n] = size(A);
  18. if m > 1
  19.    d = sum(abs(R'));
  20. else
  21.    d = abs(R');
  22. end
  23. nul = find(d <= tol);
  24. % Use columns n of Q'.
  25. if length(nul > 0)
  26.    Q = Q(:,nul);
  27. else
  28.    Q = [];
  29. end
  30.