1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| function h = myspy(S,arg2,arg3)
%SPY Visualize sparsity pattern.
% SPY(S) plots the sparsity pattern of the matrix S.
%
% SPY(S,'LineSpec') uses the color and marker from the line
% specification string 'LineSpec' (See PLOT for possibilities).
%
% SPY(S,markersize) uses the specified marker size instead of
% a size which depends upon the figure size and the matrix order.
%
% SPY(S,'LineSpec',markersize) sets both.
%
% SPY(S,markersize,'LineSpec') also works.
% Copyright 1984-2004 The MathWorks, Inc.
% $Revision: 5.19.4.3 $ $Date: 2004/07/05 17:01:42 $
cax = newplot;
next = lower(get(cax,'NextPlot'));
hold_state = ishold;
marker = ''; color = ''; markersize = 0; linestyle = 'none';
if nargin >= 2
if ischar(arg2),
[line,color,marker,msg] = colstyle(arg2);
if ~isempty(msg)
error('MATLAB:spy:InvalidLinespecString', msg)
end
else
markersize = arg2;
end
end
if nargin >= 3
if ischar(arg3),
[line,color,marker,msg] = colstyle(arg3);
if ~isempty(msg)
error('MATLAB:spy:InvalidLinespecString', msg)
end
else
markersize = arg3;
end
end
if isempty(marker), marker = '.'; end
if isempty(color), co = get(cax,'colororder'); color = co(1,:); end
if nargin < 1, S = defaultspy; end
[m,n] = size(S);
if marker~='.' && markersize==0,
markersize = get(gcf,'defaultlinemarkersize');
end
if markersize == 0
units = get(gca,'units');
set(gca,'units','points');
pos = get(gca,'position');
markersize = max(4,min(14,round(6*min(pos(3:4))/max(m+1,n+1))));
set(gca,'units',units);
end
[i,j] = find(S);
if isempty(i), i = NaN; j = NaN; end
if isempty(S), marker = 'none'; end
h = plot(j,i,'marker',marker,'markersize',markersize, ...
'linestyle',linestyle,'color',color);
xlabel(['nz = ' int2str(nnz(S))]);
set(gca,'xlim',[0 n+1],'ylim',[0 m+1],'ydir','reverse', ...
'grid','none','plotboxaspectratio',[n+1 m+1 1]);
if ~hold_state, set(cax,'NextPlot',next); end
% ------------------------------------------------------
function S = defaultspy
c = [';@3EA4:aei7]ced.CFHE;4\T>*Y>,dL0,HOQQMJLJE9PX[[Q.ZF.\JTCA1dd'
'<A;FB:;bfj8^df//DGIF<5]UF+ZH-eM>-IorRPNMPIE-Y\\R8[I8]SUDW2e+'
'=4BGC;<cgk9_e00DEOJG=6^VG,[I.fN?5jpsSQPNQPF.Z,]S9`S9cTWVX:+,'
':5CHD<=4hlh`f11EFPKHA7&WH-\J/gOC?kqtTRRORQJ8--^TB+T=dWYWY;,_'
';6D3E=>7imiag2IFOQLID8''XI.]K0"PD@l32UZhP//P988_WC,U>+Z^Y\<2`'
'<82BF>?8jnjbhLJGPRMJE9/YJ/`L1#QMC$;;V[iv09QE99,XD.YB,[_\]=3a'
'>9;CG?@9kokc2MKHQSOKF:0ZL0aM2$RNG%AAW\jw9E.FEE-_G8aG.d`]_W5+'
'?:CDH@A:lpld3NLIRTPLG=1[M1bN3%SOH4BBX]kx:J9LLL8`H9bJ/+d_dX6,'
'@;DEIAB;mqmePOMJSUQMJ>2\N2cO4&TPP@HCY^lyDKEMMN9+I@+S8,+deY7^'
'8@EFJBC<4rnfQPNPTVRNKB3]O3dP5''UQQCIDZ_mzEPFNNOE,RA,T9/,++\8_'
'9A2G3CD=544gRQPQUWUOLE4^P4"Q6(VRRIJE[`n{KQKOOPK-SE.W:F/,,]Z+'
':BDH4DE>655hSRQRVXVPMF5_Q5#R>)eSSJKF\ao0L.L-WUL.VF8XCH001_[,'
';3EI<EO?766iTSRSWYWQNG6$R6''S?*fTTlLQ]bp1M/P.XVP8[H9]DIDA=`\]'
'?4D3=FP@877jUTSTXZXROK7%S7(TF+gUUmMR^cq:N9Q8YZQ9_I>cIJEB>d_^'
'@5E@>GQA98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