1function 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-98 by The MathWorks, Inc. 12% $Revision: 5.3 $ $Date: 1997/11/21 23:27:12 $ 13 14if (nargin < 3), cp = rp; end 15 16spy(S) 17hold on 18 19[m,n] = size(S); 20if length(rp) > 2 21 k = length(rp)-2; 22 X = [zeros(1,k); n+ones(1,k)]; 23 Y = rp(2:k+1) - 0.5; 24 Y = [Y; Y]; 25 plot(X,Y,'w-') 26end 27if length(cp) > 2 28 k = length(cp)-2; 29 X = cp(2:k+1) - .5; 30 X = [X; X]; 31 Y = [zeros(1,k); m+ones(1,k)]; 32 plot(X,Y,'w-') 33end 34axis('ij') 35hold off 36