# HG changeset patch # User LYH # Date 1380142040 -28800 # Node ID 9b2443f97a3e6df9f3674b4c658e0c31ba284207 # Parent e8d3d5a5a867d94f6159d94fc263a75cbf287bd7# Parent 89ffc9c786e5f0446e2b1ab108ec3f060254f9cb Merge the official development diff --git a/scripts/plot/meshgrid.m b/scripts/plot/meshgrid.m --- a/scripts/plot/meshgrid.m +++ b/scripts/plot/meshgrid.m @@ -46,9 +46,9 @@ ## Programming Note: @code{meshgrid} is restricted to 2-D or 3-D grid ## generation. The @code{ndgrid} function will generate 1-D through N-D ## grids. However, the functions are not completely equivalent. If @var{x} -## is a vector of length M and @var{y} is a vector of length N, then @code -## meshgrid will produce an output grid which is NxM. @code{ndgrid} will -## produce an output which is MxN for the same input. +## is a vector of length M and @var{y} is a vector of length N, then +## @code{meshgrid} will produce an output grid which is NxM. @code{ndgrid} +## will produce an output which is MxN for the same input. ## @seealso{ndgrid, mesh, contour, surf} ## @end deftypefn diff --git a/scripts/plot/sombrero.m b/scripts/plot/sombrero.m --- a/scripts/plot/sombrero.m +++ b/scripts/plot/sombrero.m @@ -57,20 +57,18 @@ error ("sombrero: number of grid lines N must be greater than 1"); endif - tx = linspace (-8, 8, n)'; - ty = tx; - [xx, yy] = meshgrid (tx, ty); - r = sqrt (xx .^ 2 + yy .^ 2) + eps; # eps prevents div/0 errors - tz = sin (r) ./ r; + [xx, yy] = meshgrid (linspace (-8, 8, n)); + r = sqrt (xx.^2 + yy.^2) + eps; # eps prevents div/0 errors + zz = sin (r) ./ r; if (nargout == 0) - surf (tx, ty, tz); + surf (xx, yy, zz); elseif (nargout == 1) - x = tz; + x = zz; else - x = tx; - y = ty; - z = tz; + x = xx; + y = yy; + z = zz; endif endfunction