MATLAB: How to write function to find minimum of function with two variables

functionsMATLABmatrix manipulation

I have a function in two variables suppose . How to find min(J)?

Best Answer

  1. fmincon(), fminunc() -- search for local minima
  2. fminsearch() -- also a local minimizer but one that is a bit better at not getting caught in valleys
  3. ga(), patternsearch(), particleswarm() -- searchers that use heuristics to try to search globally. None of these promise to find the global minima though
  4. Some of the above can be used together with multistart() and similar techniques to give a better opportunity at finding global minima
  5. If you have the symbolic toolbox, use calculas. min(J) occurs at either a boundary (if there are constraints) or else at a point at which diff(J) == 0 . So differentiate and use one of the techniques for solving for zeros. Once you have the locations of the zeros, you can evaluate J'' at the location in order to test whether what you found was a maxima or minima or saddle point.