Home > freetb4matlab > general > gradient.m

gradient

PURPOSE ^

%

SYNOPSIS ^

function varargout = gradient (m, varargin)

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {@var{dx} =} gradient (@var{m})
% @deftypefnx {Function File} {[@var{dx}, @var{dy}, @var{dz}, @dots{}] =} gradient (@var{m})
% @deftypefnx {Function File} {[@dots{}] =} gradient (@var{m}, @var{s})
% @deftypefnx {Function File} {[@dots{}] =} gradient (@var{m}, @var{x}, @var{y}, @var{z}, @dots{})
% @deftypefnx {Function File} {[@dots{}] =} gradient (@var{f}, @var{x0})
% @deftypefnx {Function File} {[@dots{}] =} gradient (@var{f}, @var{x0}, @var{s})
% @deftypefnx {Function File} {[@dots{}] =} gradient (@var{f}, @var{x0}, @var{x}, @var{y}, @dots{})
%
% Calculate the gradient of sampled data or a function.  If @var{m}
% is a vector, calculate the one-dimensional gradient of @var{m}.  If
% @var{m} is a matrix the gradient is calculated for each dimension.
%
% @code{[@var{dx}, @var{dy}] = gradient (@var{m})} calculates the one
% dimensional gradient for @var{x} and @var{y} direction if @var{m} is a
% matrix.  Additional return arguments can be use for multi-dimensional
% matrices.
%
% A constant spacing between two points can be provided by the
% @var{s} parameter.  If @var{s} is a scalar, it is assumed to be the spacing
% for all dimensions. 
% Otherwise, separate values of the spacing can be supplied by
% the @var{x}, @dots{} arguments.  Scalar values specify an equidistant spacing.
% Vector values for the @var{x}, @dots{} arguments specify the coordinate for that
% dimension.  The length must match their respective dimension of @var{m}.
% 
% At boundary points a linear extrapolation is applied.  Interior points
% are calculated with the first approximation of the numerical gradient
%
% @example
% y'(i) = 1/(x(i+1)-x(i-1)) * (y(i-1)-y(i+1)).
% @end example
% 
% If the first argument @var{f} is a function handle, the gradient of the
% function at the points in @var{x0} is approximated using central
% difference.  For example, @code{gradient (@@cos, 0)} approximates the
% gradient of the cosine function in the point @math{x0 = 0}.  As with
% sampled data, the spacing values between the points from which the
% gradient is estimated can be set via the @var{s} or @var{dx},
% @var{dy}, @dots{} arguments.  By default a spacing of 1 is used.
% @seealso{diff, del2}
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Fri 22-May-2009 15:13:00 by m2html © 2003