meshgrid
Generate X, Y coordinate matrices for grid evaluation.
Syntax
Section titled “Syntax”[X, Y] = meshgrid(x, y)[X, Y] = meshgrid(x)[X, Y, Z] = meshgrid(x, y, z)Description
Section titled “Description”Returns matrices X and Y such that X(i, j) = x(j) and Y(i, j) = y(i) — the natural shape for evaluating f(X, Y) on a 2D grid. With three arguments, returns 3D coordinate arrays. With one argument, uses it for both x and y.
Examples
Section titled “Examples”[X, Y] = meshgrid(-2:0.1:2);Z = sin(X) .* cos(Y);