autoJac
Estimate the gradient or Jacobian of a function via automatic differentiation
Syntax
jac = autoJac(fun,x)
Description
This function uses William McIlhagga's adiff package to estimate the gradient or Jacobian at a value of x using forward automatic differentiation.
jac = autoJac(fun,x) uses the function handle fun and the current state vector x to estimate the gradient / Jacobian of the function fun.
Example
Estimate the Jacobian of the following nonlinear constraint function at x = [1 1 1 1]T:
nlcon = @(x) [8 - x(1)^2 - x(2)^2 - x(3)^2 - x(4)^2 - x(1) + x(2) - x(3) + x(4);
10 - x(1)^2 - 2*x(2)^2 - x(3)^2 - 2*x(4)^2 + x(1) + x(4);
5 - 2*x(1)^2 - x(2)^2 - x(3)^2 - 2*x(1) + x(2) + x(4)];
x = [1;1;1;1];
jac = autoJac(nlcon,x)
jac =
-3 -1 -3 -1
-1 -4 -2 -3
-6 -1 -2 1
Copyright © 2011-2013 Jonathan Currie (I2C2)