7017
|
1 ## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
8920
|
2 ## 2007, 2008, 2009 Andy Adler |
7016
|
3 ## |
|
4 ## This file is part of Octave. |
5164
|
5 ## |
7016
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
5164
|
10 ## |
7016
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
5164
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
5164
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} spy (@var{x}) |
6607
|
22 ## @deftypefnx {Function File} {} spy (@dots{}, @var{markersize}) |
8507
|
23 ## @deftypefnx {Function File} {} spy (@dots{}, @var{line_spec}) |
6607
|
24 ## Plot the sparsity pattern of the sparse matrix @var{x}. If the argument |
|
25 ## @var{markersize} is given as an scalar value, it is used to determine the |
8507
|
26 ## point size in the plot. If the string @var{line_spec} is given it is |
6607
|
27 ## passed to @code{plot} and determines the appearance of the plot. |
|
28 ## @seealso{plot} |
5164
|
29 ## @end deftypefn |
|
30 |
8507
|
31 function spy (x, varargin) |
6607
|
32 |
7125
|
33 if (nargin < 1) |
|
34 print_usage (); |
|
35 endif |
|
36 |
6607
|
37 markersize = NaN; |
|
38 if (numel (i) < 1000) |
8507
|
39 line_spec = "*"; |
6607
|
40 else |
8507
|
41 line_spec = "."; |
6607
|
42 endif |
8507
|
43 for i = 1:length (varargin) |
|
44 if (ischar (varargin{i})) |
|
45 line_spec = varargin{i}; |
6607
|
46 elseif (isscalar (varargin{i})) |
|
47 markersize = varargin{i}; |
|
48 else |
|
49 error ("spy: expected markersize or linespec"); |
|
50 endif |
|
51 endfor |
6446
|
52 |
8507
|
53 [i, j, s] = find (x); |
|
54 [m, n] = size (x); |
5164
|
55 |
6607
|
56 if (isnan (markersize)) |
8507
|
57 plot (j, i, line_spec); |
6446
|
58 else |
8507
|
59 plot (j, i, line_spec, "markersize", markersize); |
6446
|
60 endif |
5164
|
61 |
6674
|
62 axis ([0, n+1, 0, m+1], "ij"); |
5164
|
63 |
|
64 endfunction |