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

  1. function h = hankel(c,r)
  2. %HANKEL    Hankel matrix.
  3. %    HANKEL(C) is a square Hankel matrix whose first column is C and
  4. %    whose elements are zero below the first anti-diagonal.
  5. %    HANKEL(C,R) is a Hankel matrix whose first column is C and whose
  6. %    last row is R.
  7. %    Hankel matrices are symmetric, constant across the anti-diagonals,
  8. %    and have elements H(i,j) = R(i+j-1).
  9. %
  10. %    See also TOEPLITZ.
  11.  
  12. %    J.N. Little 4-22-87
  13. %    Revised 1-28-88 JNL
  14. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  15.  
  16. c = c(:);
  17. nc = max(size(c));
  18.  
  19. if nargin == 1
  20.     h = zeros(nc,nc);
  21.     for j=1:nc
  22.         h(1:nc-j+1,j) = c(j:nc);
  23.     end
  24. else
  25.     r = r(:);
  26.     nr = max(size(r));
  27.     h = zeros(nc,nr);
  28.     if c(nc) ~= r(1)
  29.         disp(' ')
  30.         disp('Column wins anti-diagonal conflict.')
  31.     end
  32.     for j=1:nr
  33.         if j <= nc
  34.             h(:,j) = [c(j:nc); r(2:j)];
  35.         else
  36.             h(:,j) = r(j-nc+1:j);
  37.         end
  38.     end
  39. end
  40.