home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 3.ddi / DEMOS.DI$ / SPYPART.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  829 b   |  35 lines

  1. function spypart(S, rp, cp);
  2. %SPYPART Spy plot with partitioning.
  3. %    SPYPART(S,rp,cp) plots the sparsity pattern of a matrix S,
  4. %    with lines marking a block partition described by 
  5. %    rp (rows) and cp (columns).
  6. %    If S is square, cp may be omitted and defaults to rp.
  7. %
  8. %    Partitions are specified as in the output of DMPERM:
  9. %    There are length(rp)-1 row blocks, of sizes diff(rp), with rp(1)=1.
  10.  
  11. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  12.  
  13. if (nargin < 3), cp = rp; end
  14.  
  15. spy(S)
  16. hold on
  17.  
  18. [m,n] = size(S);
  19. if length(rp) > 2
  20.    k = length(rp)-2;
  21.    X = [zeros(1,k); n+ones(1,k)];
  22.    Y = rp(2:k+1) - 0.5;
  23.    Y = [Y; Y];
  24.    plot(X,Y,'w-') 
  25. end
  26. if length(cp) > 2
  27.    k = length(cp)-2;
  28.    X = cp(2:k+1) - .5;
  29.    X = [X; X];
  30.    Y = [zeros(1,k); m+ones(1,k)];
  31.    plot(X,Y,'w-') 
  32. end
  33. axis('ij')
  34. hold off
  35.