Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Rectangular grid in N-D space

```
[X1,X2,...,Xn]
= ndgrid(x1,x2,...,xn)
```

```
[X1,X2,...,Xn]
= ndgrid(xg)
```

`[`

replicates the grid vectors `X1,X2,...,Xn`

]
= ndgrid(`x1,x2,...,xn`

)`x1,x2,...,xn`

to produce an
`n`

-dimensional full grid.

`[`

specifies a single grid vector `X1,X2,...,Xn`

]
= ndgrid(`xg`

)`xg`

to use for all dimensions. The
number of output arguments you specify determines the dimensionality
`n`

of the output.

The

`ndgrid`

function is similar to`meshgrid`

. However,`ndgrid`

supports 1-D to N-D while`meshgrid`

is restricted to 2-D and 3-D.