From: Mehdi on
Hello everyone,
I am using fmincon to obtain 3 parameters that all are positive real
numbers. However, Matlab gives me complex values. Is there any way to
define the constraints so Matlab only consider real values while
searching for the minimum?

Thank you,
Mehdi
From: Matt on
Mehdi <zeidouni(a)gmail.com> wrote in message <cc984186-51dc-4636-b87a-0eb55d1eae41(a)y28g2000prd.googlegroups.com>...
> Hello everyone,
> I am using fmincon to obtain 3 parameters that all are positive real
> numbers. However, Matlab gives me complex values. Is there any way to
> define the constraints so Matlab only consider real values while
> searching for the minimum?


MATLAB already does only consider only real values.

If you're seeing complex numbers, it's probably because your iterations crossed some natural boundary where the evaluation of the function and its gradient mistakenly produced complex numbers. For example, this could occur if you have log(Arg) expressions in your gradient and Arg strayed negative, at which point fmincon would start to update your variables using complex arithmetic.

Make sure you have applied constraints such that Arg>0, in addition to constraints on the variables themselves.