function varargout = gradient(f,varargin)
%GRADIENT Approximate gradient.
% [FX,FY] = GRADIENT(F) returns the numerical gradient of the
% matrix F. FX corresponds to dF/dx, the differences in x (horizontal)
% direction. FY corresponds to dF/dy, the differences in y (vertical)
% direction. The spacing between points in each direction is assumed to
% be one. When F is a vector, DF = GRADIENT(F) is the 1-D gradient.
%
% [FX,FY] = GRADIENT(F,H), where H is a scalar, uses H as the
% spacing between points in each direction.
%
% [FX,FY] = GRADIENT(F,HX,HY), when F is 2-D, uses the spacing
% specified by HX and HY. HX and HY can either be scalars to specify
% the spacing between coordinates or vectors to specify the
% coordinates of the points. If HX and HY are vectors, their length
% must match the corresponding dimension of F.
%
% [FX,FY,FZ] = GRADIENT(F), when F is a 3-D array, returns the
% numerical gradient of F. FZ corresponds to dF/dz, the differences
% in the z direction. GRADIENT(F,H), where H is a scalar,
% uses H as the spacing between points in each direction.
%
% [FX,FY