??? Error using ==> barrier at 14
Objective function is undefined at initial point. Fmincon cannot continue.
what could be the reason?
Well....? Is it true?
Your call to fmincon probably looks something like
fmincon(obj,x0, ...)
The error message indicates that your objective function "obj" either
errors, or returns and invalid value such as Inf, NaN or a complex
number when evaluated at the point x0.
You may want to evaluate your function at x0 before calling fmincon to
see if it's well defined: something like
>> obj(x0)
-Marcelo
Error in ==> fmincon at 797
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options_ip.HessFcn, ...
Error in ==> Step4base at 6
x
=fmincon(@(x)fGlobal(x,Data),StartingNSb,[],[],[],[],[],[],@(x)myconstr(x,EGAM),options);
Although I checked the two functions fglobal and myconstr by running fglobal(StartingNSb,Data) which results 0.2438 + 0.0000i and by running mtconstr(StartingNSb,EGAM) which is returning [] without any error.
Kindly advise.
> Error in ==> Step4base at 6
> x
> =fmincon(@(x)fGlobal(x,Data),StartingNSb,[],[],[],[],[],[],@(x)myconstr(x,EGAM),options);
>
> Although I checked the two functions fglobal and myconstr by running fglobal(StartingNSb,Data) which results 0.2438 + 0.0000i and by running mtconstr(StartingNSb,EGAM) which is returning [] without any error.
> Kindly advise.
=============
Your function fglobal is returning a complex-valued result. The imaginary value is obviously small, but is not zero, even if it looks that way when displayed to 4 decimal places . If this imaginary part is purely due to round-off errors, use real() to strip it away.
Thanks Matt. It is working now.