Back to Core Functions
meshgrid
Create 2D coordinate matrices
Syntax
[X, Y] = meshgrid(x, y) [X, Y] = meshgrid(v) [X, Y] = meshgrid(x, y, 'ij')
Description
Returns coordinate matrices from coordinate vectors. For vectors x and y, meshgrid returns 2D matrices X and Y where X has x values repeated across rows and Y has y values repeated down columns (MATLAB 'xy' indexing). With a single argument v, uses v for both x and y. An optional 'ij' argument switches to NumPy-style matrix indexing where X varies along the first dimension.
Parameters
| Name | Description |
|---|---|
| x | X-coordinate vector |
| y(optional) | Y-coordinate vector (defaults to x if omitted) |
| indexing(optional) | Indexing mode: 'xy' (default, MATLAB style) or 'ij' (NumPy matrix style) |
Returns
Two NDArrays [X, Y] of coordinate matrices