`meshgrid`

and `ndgrid`

create grids
using different output formats. Specifically, the first two dimensions of a grid created using
one of these functions are swapped when compared to the other grid format. Some MATLAB^{®} functions use grids in `meshgrid`

format, while others use
`ndgrid`

format, so it is common to convert grids between the two
formats.

You can convert between these grid formats using `pagetranspose`

(*as of R2020b*) or `permute`

to swap the first two dimensions of the grid arrays. For example, create a 3-D grid with `meshgrid`

.

Now transpose the first two dimensions of each grid array to convert the grid to `ndgrid`

format, and compare the results against the outputs from `ndgrid`

.

Using `pagetranspose`

is equivalent to permuting the first two dimensions while leaving other dimensions the same. You can also perform this operation using `permute(X,[2 1 3:ndims(X)])`

.