|MATLAB Function Reference|
Generate arrays for multidimensional functions and interpolation
[X1,X2,X3,...] = ndgrid(x1,x2,x3,...)
transforms the domain specified by vectors
x3... into arrays
X3... that can be used for the evaluation of functions of multiple variables and multidimensional interpolation. The
ith dimension of the output array
Xi are copies of elements of the vector
[X1,X2,...] = ndgrid(x)
is the same as
[X1,X2,...] = ndgrid(x,x,...).
Evaluate the function
over the range .
ndgrid function is like
meshgrid except that the order of the first two input arguments are switched. That is, the statement
produces the same result as
Because of this,
ndgrid is better suited to multidimensional problems that aren't spatially based, while
meshgrid is better suited to problems in two- or three-dimensional Cartesian space.