# HG changeset patch # User Rik # Date 1380152746 25200 # Node ID db92cd6117a930505262844a90ae0fdb059e91be # Parent cd98a50bfa6350a8453893a6b4c57b195c52c870 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. diff --git a/scripts/plot/meshgrid.m b/scripts/plot/meshgrid.m --- 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 diff --git a/scripts/plot/ndgrid.m b/scripts/plot/ndgrid.m --- 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