annotate scripts/plot/sombrero.m @ 16491:b10a23fe80bb

doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility. * scripts/audio/wavread.m, scripts/miscellaneous/getappdata.m, scripts/miscellaneous/license.m, scripts/miscellaneous/ver.m, scripts/plot/daspect.m, scripts/plot/graphics_toolkit.m, scripts/plot/pbaspect.m, scripts/polynomial/splinefit.m, scripts/set/union.m, scripts/signal/freqz.m: Improve docstring wording.
author Rik <rik@octave.org>
date Wed, 10 Apr 2013 22:43:30 -0700
parents befb99c0c72f
children 64e7bb01fce2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14092
diff changeset
1 ## Copyright (C) 1993-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
18
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 2847
diff changeset
19 ## -*- texinfo -*-
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 2847
diff changeset
20 ## @deftypefn {Function File} {} sombrero (@var{n})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6278
diff changeset
21 ## Produce the familiar three-dimensional sombrero plot using @var{n}
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6278
diff changeset
22 ## grid lines. If @var{n} is omitted, a value of 41 is assumed.
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6278
diff changeset
23 ##
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6278
diff changeset
24 ## The function plotted is
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
25 ##
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 2847
diff changeset
26 ## @example
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6278
diff changeset
27 ## z = sin (sqrt (x^2 + y^2)) / (sqrt (x^2 + y^2))
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 2847
diff changeset
28 ## @end example
7282
30100a15625c [project @ 2007-12-10 21:42:11 by jwe]
jwe
parents: 7245
diff changeset
29 ## @seealso{surf, meshgrid, mesh}
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 2847
diff changeset
30 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
31
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
32 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
33
15176
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
34 function [x, y, z] = sombrero (n = 41)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
35
15176
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
36 if (nargin > 2)
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
37 print_usage ();
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
38 elseif (n <= 1)
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
39 error ("sombrero: number of grid lines N must be greater than 1");
5381
75f308189a05 [project @ 2005-06-05 13:19:20 by jwe]
jwe
parents: 5307
diff changeset
40 endif
75f308189a05 [project @ 2005-06-05 13:19:20 by jwe]
jwe
parents: 5307
diff changeset
41
15176
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
42 tx = linspace (-8, 8, n)';
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
43 ty = tx;
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
44 [xx, yy] = meshgrid (tx, ty);
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
45 r = sqrt (xx .^ 2 + yy .^ 2) + eps;
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
46 tz = sin (r) ./ r;
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
47 if (nargout == 0)
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
48 surf (tx, ty, tz);
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
49 box ("off");
5381
75f308189a05 [project @ 2005-06-05 13:19:20 by jwe]
jwe
parents: 5307
diff changeset
50 else
15176
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
51 x = tx;
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
52 y = ty;
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
53 z = tz;
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
54 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
55
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
56 endfunction
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
57
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
58
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
59 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
60 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
61 %! colormap ('default');
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7017
diff changeset
62 %! sombrero ();
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
63
15176
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
64 ## Test input validation
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
65 %!error sombrero (1,2,3)
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
66 %!error <N must be greater than 1> sombrero (1)
befb99c0c72f sombrero.m: Put input validation first and add %!tests.
Rik <rik@octave.org>
parents: 14247
diff changeset
67