gradfun

gradfun('fun',x) evaluates the gradient of the function 'fun' at a given point x. This function uses complex differentiation.

You are now following this Submission

function g = gradfun(fun,x)
% gradfun('fun',x) evaluates the gradient of the function 'fun' at the
% point x = [x1,..., xn]. This function uses complex differentiation.
%
% Example:
%
% f = @(x) 10*cos(x(1))*sin(x(2)) + x(1)^2 - 2*x(2)^2 + 10;
% x0 = [pi; -pi];
% g0 = gradfun(f, x0)
%
% Returns the value of the gradient of f at x0, which is [6.2832; 22.5664].
%
% Contact info:
%
% Andres Tovar
% tovara@iupui.edu
% Indiana University-Purdue University Indianapolis

Cite As

Andres Tovar (2026). gradfun (https://www.mathworks.com/matlabcentral/fileexchange/69994-gradfun), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0