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

  1. %DIAG    Create or extract diagonals.
  2. %    If V is a row or column vector with N components,
  3. %     DIAG(V,K) is a square matrix of order N+ABS(K) with the
  4. %     elements of V on the K-th diagonal. K = 0 is the main
  5. %     diagonal, K > 0 is above the main diagonal and K < 0 is
  6. %     below the main diagonal. DIAG(V) simply puts V on the
  7. %     main diagonal. For example,
  8. %     DIAG(-M:M) + DIAG(ONES(2*M,1),1) + DIAG(ONES(2*M,1),-1)
  9. %     produces a tridiagonal matrix of order 2*M+1.
  10. %     If X is a matrix, DIAG(X,K) is a column vector formed from
  11. %     the elements of the K-th diagonal of X. DIAG(X) is the main
  12. %     diagonal of X. DIAG(DIAG(X)) is a diagonal matrix.
  13.  
  14. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  15. %    Built-in function.
  16.