Mercurial > hg > octave-nkf
annotate scripts/sparse/spy.m @ 11523:fd0a3ac60b0e
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 05:47:45 -0500 |
parents | be55736a0783 |
children | c792872f8942 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1998-2011 Andy Adler |
7016 | 2 ## |
3 ## This file is part of Octave. | |
5164 | 4 ## |
7016 | 5 ## Octave is free software; you can redistribute it and/or modify it |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
5164 | 9 ## |
7016 | 10 ## Octave is distributed in the hope that it will be useful, but |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
5164 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5164 | 18 |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10714
diff
changeset
|
20 ## @deftypefn {Function File} {} spy (@var{x}) |
6607 | 21 ## @deftypefnx {Function File} {} spy (@dots{}, @var{markersize}) |
8507 | 22 ## @deftypefnx {Function File} {} spy (@dots{}, @var{line_spec}) |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
23 ## Plot the sparsity pattern of the sparse matrix @var{x}. If the argument |
6607 | 24 ## @var{markersize} is given as an scalar value, it is used to determine the |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
25 ## point size in the plot. If the string @var{line_spec} is given it is |
6607 | 26 ## passed to @code{plot} and determines the appearance of the plot. |
27 ## @seealso{plot} | |
5164 | 28 ## @end deftypefn |
29 | |
8507 | 30 function spy (x, varargin) |
6607 | 31 |
7125 | 32 if (nargin < 1) |
33 print_usage (); | |
34 endif | |
35 | |
6607 | 36 markersize = NaN; |
10714 | 37 if (numel (x) < 1000) |
8507 | 38 line_spec = "*"; |
6607 | 39 else |
8507 | 40 line_spec = "."; |
6607 | 41 endif |
8507 | 42 for i = 1:length (varargin) |
43 if (ischar (varargin{i})) | |
44 line_spec = varargin{i}; | |
6607 | 45 elseif (isscalar (varargin{i})) |
46 markersize = varargin{i}; | |
47 else | |
48 error ("spy: expected markersize or linespec"); | |
49 endif | |
50 endfor | |
6446 | 51 |
8507 | 52 [i, j, s] = find (x); |
53 [m, n] = size (x); | |
5164 | 54 |
6607 | 55 if (isnan (markersize)) |
8507 | 56 plot (j, i, line_spec); |
6446 | 57 else |
8507 | 58 plot (j, i, line_spec, "markersize", markersize); |
6446 | 59 endif |
5164 | 60 |
6674 | 61 axis ([0, n+1, 0, m+1], "ij"); |
5164 | 62 |
63 endfunction |