changeset 17512:db92cd6117a9

ndgrid.m: Add explanation of differences with meshgrid to docstring. * scripts/plot/meshgrid.m: Add more explanation of differences with ndgrid to docstring. * scripts/plot/ndgrid.m: Add explanation of differences with meshgrid to docstring.
author Rik <rik@octave.org>
date Wed, 25 Sep 2013 16:45:46 -0700
parents cd98a50bfa63
children 5789ad69c85a
files scripts/plot/meshgrid.m scripts/plot/ndgrid.m
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/meshgrid.m
+++ b/scripts/plot/meshgrid.m
@@ -36,19 +36,24 @@
 ## plot of the ``sombrero'' function.
 ##
 ## @example
+## @group
 ## f = @@(x,y) sin (sqrt (x.^2 + y.^2)) ./ sqrt (x.^2 + y.^2);
 ## range = linspace (-8, 8, 41);
 ## [@var{X}, @var{Y}] = meshgrid (range, range);  
 ## Z = f (X, Y);
 ## surf (X, Y, Z);
+## @end group
 ## @end example
 ##
 ## 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.
+## @code{meshgrid} will produce an output grid which is NxM@.  @code{ndgrid}
+## will produce an output which is MxN (transpose) for the same input.  Some
+## core functions expect @code{meshgrid} input and others expect @code{ndgrid}
+## input.  Check the documentation for the function in question to determine
+## the proper input format.
 ## @seealso{ndgrid, mesh, contour, surf}
 ## @end deftypefn
 
--- a/scripts/plot/ndgrid.m
+++ b/scripts/plot/ndgrid.m
@@ -19,14 +19,20 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x1}, @var{x2}, @dots{}, @var{x}n)
 ## @deftypefnx {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x})
-## Given n vectors @var{x1}, @dots{} @var{x}n, @code{ndgrid} returns
+## Given n vectors @var{x1}, @dots{}, @var{x}n, @code{ndgrid} returns
 ## n arrays of dimension n.  The elements of the i-th output argument
 ## contains the elements of the vector @var{x}i repeated over all
 ## dimensions different from the i-th dimension.  Calling ndgrid with
-## only one input argument @var{x} is equivalent of calling ndgrid with
+## only one input argument @var{x} is equivalent to calling ndgrid with
 ## all n input arguments equal to @var{x}:
 ##
 ## [@var{y1}, @var{y2}, @dots{}, @var{y}n] = ndgrid (@var{x}, @dots{}, @var{x})
+##
+## Programming Note: @code{ndgrid} is very similar to the function
+## @code{meshgrid} except that the first two dimensions are transposed in
+## comparison to @code{meshgrid}.  Some core functions expect @code{meshgrid}
+## input and others expect @code{ndgrid} input.  Check the documentation for
+## the function in question to determine the proper input format.
 ## @seealso{meshgrid}
 ## @end deftypefn