Mercurial > octave-nkf
annotate scripts/plot/sombrero.m @ 14092:22c50cbad2ce stable
Add clf() to all plot demos.
* axis.m, compass.m, contour3.m, contourf.m, cylinder.m, ellipsoid.m,
errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m,
ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fplot.m,
loglogerr.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m,
quiver.m, quiver3.m, refreshdata.m, ribbon.m, rose.m, scatter3.m,
semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shading.m,
sombrero.m, stairs.m, stem.m, stem3.m, surf.m, surfc.m, surfl.m,
surfnorm.m, trimesh.m, triplot.m, trisurf.m, uimenu.m:
Add clf() to the beginning of each demo to ensure pre-existing graphics
objects don't interfere with the demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 21 Dec 2011 21:19:48 -0500 |
parents | a754c2d8a13f |
children | 72c96de7a403 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1993-2011 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 |
64 %!demo | |
14092
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
12437
diff
changeset
|
65 %! clf |
7245 | 66 %! sombrero (); |