Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose we have to minimize a function $f(X,Y)-g(X,Y)$, where both the functions are convex. How can this be solved in matlab? Is there any tool to solve this in matlab?

share|cite|improve this question

There are a lot of optimization functions in Matlab. Which to choose depends on the functions $f$ and $g$. For example, you can try fminunc, especially if you know first or second derivatives, or fminsearch for a derivative-free method.

However, note that the difference of convex function is not in general a convex function, so you can get stuck in local minimum.

share|cite|improve this answer
Sir when X is a matrix and Y is some column matrix then how it can be fit using fminsearch.. – user3256924 Feb 26 '14 at 10:23
X and Y can be treat as one big vector of unknowns. However, it will be extremely slow without derivatives. – felagund Feb 26 '14 at 10:29
use reshape() function to convert matrix to vector and back vector to matrix. – felagund Feb 26 '14 at 10:46
suppose $f(X,Y)=|l*X*h|^2/(Y(1,:)+0.01)$, then how it can be written using fminsearch . will you help me in writing the code for this? – user3256924 Feb 26 '14 at 10:50
Sorry sir but unable to understand.. – user3256924 Feb 26 '14 at 10:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.