Skip to content

gradient

Numerical gradient of a scalar field.

[Fx, Fy] = gradient(F)
[Fx, Fy, Fz] = gradient(F)
[Fx, Fy] = gradient(F, hx, hy)

Returns the numerical gradient of F along each dimension. hx/hy (default 1) are the grid spacings; for non-uniform grids, pass coordinate vectors.

[gx, gy] = gradient(peaks(50));
quiver(gx, gy)
  • divergence — Divergence of a vector field.
  • curl — Curl of a vector field.
  • diff — Differences between adjacent elements.