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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>SPY Visualize Sparsity Pattern of a Sparse Matrix
</TITLE>
</HEAD>
<BODY>
<H2>SPY Visualize Sparsity Pattern of a Sparse Matrix
</H2>
<P>
Section: <A HREF=sec_sparse.html> Sparse Matrix Support </A>
<H3>Usage</H3>
Plots the sparsity pattern of a sparse matrix. The syntax for its use is
<PRE>
spy(x)
</PRE>
<P>
which uses a default color and symbol. Alternately, you can use
<PRE>
spy(x,colspec)
</PRE>
<P>
where <code>colspec</code> is any valid color and symbol spec accepted by <code>plot</code>.
<H3>Example</H3>
First, an example of a random sparse matrix.
<PRE>
--> y = sprand(1000,1000,.001);
--> spy(y,'ro')
</PRE>
<P>
which is shown here
<P>
<DIV ALIGN="CENTER">
<IMG SRC="spy1.png">
</DIV>
<P>
Here is a sparse matrix with a little more structure. First we build a
sparse matrix with block diagonal structure, and then use <code>spy</code> to
visualize the structure.
<PRE>
--> A = sparse(1000,1000);
--> for i=1:25; A((1:40) + 40*(i-1),(1:40) + 40*(i-1)) = 1; end;
--> spy(A,'gx')
</PRE>
<P>
with the result shown here
<P>
<DIV ALIGN="CENTER">
<IMG SRC="spy2.png">
</DIV>
<P>
</BODY>
</HTML>
|