Mercurial > hg > octave-lyh
annotate scripts/plot/sombrero.m @ 14247:c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
* bicubic.m, interp2.m, interpn.m, griddata.m, image.m, axis.m, clabel.m,
colorbar.m, contour.m, contourf.m, cylinder.m, ezcontour.m, ezcontourf.m,
ezmesh.m, ezmeshc.m, ezsurf.m, ezsurfc.m, hold.m, pcolor.m, plotyy.m,
quiver3.m, ribbon.m, shading.m, slice.m, sombrero.m, surf.m, surfc.m,
surfnorm.m, trisurf.m: Set colormap to default at start of demos to
make them reproducible.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 22 Jan 2012 10:02:27 -0800 |
parents | 11949c9795a0 |
children | befb99c0c72f |
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 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
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. | |
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/>. | |
245 | 18 |
3446 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} sombrero (@var{n}) | |
6895 | 21 ## Produce the familiar three-dimensional sombrero plot using @var{n} |
22 ## grid lines. If @var{n} is omitted, a value of 41 is assumed. | |
23 ## | |
24 ## The function plotted is | |
2311 | 25 ## |
3446 | 26 ## @example |
6895 | 27 ## z = sin (sqrt (x^2 + y^2)) / (sqrt (x^2 + y^2)) |
3446 | 28 ## @end example |
7282 | 29 ## @seealso{surf, meshgrid, mesh} |
3446 | 30 ## @end deftypefn |
4 | 31 |
2314 | 32 ## Author: jwe |
33 | |
6049 | 34 function [x, y, z] = sombrero (n) |
4 | 35 |
5381 | 36 if (nargin == 0) |
37 n = 41; | |
38 endif | |
39 | |
40 if (nargin < 2) | |
41 if (n > 1) | |
12437
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
42 tx = linspace (-8, 8, n)'; |
a754c2d8a13f
Modify demo scripts to allow conventient conversion to Matlab compatible syntax.
Ben Abbott <bpabbott@mac.com>
parents:
11523
diff
changeset
|
43 ty = tx; |
6076 | 44 [xx, yy] = meshgrid (tx, ty); |
5381 | 45 r = sqrt (xx .^ 2 + yy .^ 2) + eps; |
6076 | 46 tz = sin (r) ./ r; |
6049 | 47 if (nargout == 0) |
7282 | 48 surf (tx, ty, tz); |
10549 | 49 box ("off"); |
6076 | 50 else |
10549 | 51 x = tx; |
52 y = ty; | |
53 z = tz; | |
6076 | 54 endif |
5381 | 55 else |
56 error ("sombrero: number of grid lines must be greater than 1"); | |
57 endif | |
58 else | |
6046 | 59 print_usage (); |
4 | 60 endif |
61 | |
62 endfunction | |
7245 | 63 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
64 |
7245 | 65 %!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
|
66 %! 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
|
67 %! colormap ('default'); |
7245 | 68 %! 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
|
69 |