image thumbnail

gradfun

version 1.0.0 (1.31 KB) by Andres Tovar
gradfun('fun',x) evaluates the gradient of the function 'fun' at a given point x. This function uses complex differentiation.

36 Downloads

Updated 15 Jan 2019

View License

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 (2021). gradfun (https://www.mathworks.com/matlabcentral/fileexchange/69994-gradfun), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!