(fx)=gradient(f)
(fx)=gradient(f,h)
(fx,fy)=gradient(f)
(fx,fy)=gradient(f,hx,hy)
Inputs  
f 
Any numeric array. 
Outputs  
y 
An array of the same size as x , which is a numerical approximation to the gradient of the function whose values at the points on a rectangular
grid are the elements of f .

x
axis is assumed to be along the rows of the matrix, and the y
axis along the columns. The gradient is computed by using backward differences, i.e., fx[i,j]=(f[i,j]f[i,j1])/hx, j>1
, with fx[i,1]=fx[i,2]
, and likewise for the second component of the gradient. If hx
or hy
is not specified, it is assumed to be 1
.