1 ## Copyright (C) 1993-2012 John W. Eaton
3 ## This file is part of Octave.
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.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} sombrero (@var{n})
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.
24 ## The function plotted is
27 ## z = sin (sqrt (x^2 + y^2)) / (sqrt (x^2 + y^2))
29 ## @seealso{surf, meshgrid, mesh}
34 function [x, y, z] = sombrero (n)
42 tx = linspace (-8, 8, n)';
44 [xx, yy] = meshgrid (tx, ty);
45 r = sqrt (xx .^ 2 + yy .^ 2) + eps;
56 error ("sombrero: number of grid lines must be greater than 1");