view scripts/plot/sombrero.m @ 4:b4df021f796c

[project @ 1993-08-08 01:26:08 by jwe] Initial revision
author jwe
date Sun, 08 Aug 1993 01:26:08 +0000
parents
children 16a24e76d6e0
line wrap: on
line source

function sombrero (n)

# usage: sombrero (n)
#
# Draw a `sombrero' in three dimensions using n grid lines.  The
# function plotted is
#
#   z = sin (x^2 + y^2) / (x^2 + y^2);

  if (nargin != 1)
    error ("usage: sombrero (n)");
  endif

  x = y = linspace (-8, 8, n)';
  [xx, yy] = meshdom (x, y);
  r = sqrt (xx .^ 2 + yy .^ 2) + eps;
  z = sin (r) ./ r;

  mesh (x, y, z);

endfunction