fmincon is a built-in MATLAB optimization solver that solves nonlinear programming problems with non-linear constraints. Constraints can be defined as linear or non-linear inequality/equality functions. Here's an example code snippet that demonstrates how to use fmincon with constraints:
main.m342 chars14 lines
In the above code:
fun is the objective function to be minimizedx0 is the initial guess for the solver to start the minimizationA,b define the linear inequality constraintoptions defines the solver options.x is the output, the optimized decision variables that minimize the given objective function.fval is the optimal objective function value of fun found by fminconexitflag is an output that indicates the exit condition of the solveroutput is a structure containing output about the number of function evaluations, algorithm iterations, etc.Please refer to MATLAB documentation for more detailed explanation of the fmincon usage and syntax.
gistlibby LogSnag