MATLAB: Derivative of Function handle (To obtain the derivative of constraints in function fmincon)

derivativefmincongceq

Hey, everyone, I'm using fmincon to solve the optimization problem under constraints. To increase the speed of calculation, I would like to provide the derivative matrix of the constraints. However, the constraint conditions are nonliner and complex, e.g as below.
where
the last one implies is also a function of . If I want to calculate the derivative of respect to , it will take a lot of efforts for me to calculate it by myself.
Does the MATLAB provide some tool to obtain the derivative of function handle, especially under using fmincon to solve the optimization problem ? Any suggestions to obtain the derivative of constraint conditions efficiently instead of calculating them by hand?

Best Answer

You can use the Symbolic Math Toolbox to obtain the expression for the derivative, and then use matlabFunction() to convert from symbolic form to function form.