Version:

Computes the gradient function of the input elements.

## Syntax

fx = gradient(f)
fx = gradient(f, d)
fx = gradient(f, dx, dy)
[fx, fy] = gradient(f)
[fx, fy] = gradient(f, d)
[fx, fy] = gradient(f, dx, dy)
[fx, fy, ...] = gradient(f)
[fx, fy, ...] = gradient(f, d)
[fx, fy, ...] = gradient(f, dx, dy, ...)

## f

Values of the function for which you want to compute the gradient. f is an array of any dimension.

## d

Spacing between points along the x- and y-axes, or between values of the first and second dimensions in a 2D array. If f is an array of a higher dimension, d is the spacing between the values of all dimensions. d is an array.

Default: 1, or dx = dy = 1.

## dx

Spacing between points along the x-axis or between values of the second dimension in a 2D or nD array. dx is an array.

Default: 1

## dy

Spacing between points along the y-axis or between values of the first dimension in a 2D or nD array. dy is an array.

Default: 1

## fx

Difference in gradient function values of f with respect to the x-axis or df/dx. fx has the same dimension as f.

## fy

Difference in gradient function values of f with respect to the y-axis or df/dy.fy has the same dimension and data type as f.

## Specifying the Spacing between Points

You can specify the spacing between the points of the gradient function in two ways. If dx or dy contains only one element, the spacing between two consecutive points in the corresponding axis is constant. If dx or dy contains more than one element, the values of the elements specify the coordinates of the points in the corresponding axis. The length of dx or dy must therefore conform to the corresponding dimension of f.

F = rand(3, 4);
[Fx, Fy] = gradient(F, [1, 2, 3, 4], [1, 2, 3])

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices