# ndgrid

Construct a grid of points from coordinate vectors.

## Syntax

[y1, y2, ...] = ndgrid(x1)

[y1, y2, ...] = ndgrid(x1, x2, ...)

## Inputs

x1, x2, ...
Coordinate vectors from which to construct a grid.
Type: double | integer
Dimension: scalar | vector | matrix

## Outputs

y1
The matrix of the x1 coordinates.
y2
The matrix of the x2 coordinates.

## Examples

One input 2D example.

x1 = [1:3];
[y1 y2] = ndgrid(x1)
y1 = [Matrix] 3 x 3
1 1 1
2 2 2
3 3 3
y2 = [Matrix] 3 x 3
1 2 3
1 2 3
1 2 3

Two input 2D example:

x1 = [1:3];
x2 = [5:8];
[y1 y2] = ndgrid(x1, x2)
y1 = [Matrix] 3 x 4
1 1 1 1
2 2 2 2
3 3 3 3
y2 = [Matrix] 3 x 4
5 6 7 8
5 6 7 8
5 6 7 8
5 6 7 8