what is this error in fmincon
3 views (last 30 days)
Show older comments
i write this code
f=@(G,r)atan((imag(((1003*G + 200*G*r + G^2*r)/(6006*G + 600) - (2004*G + 200*G*r + 1001*G^2*r + 200)^2/(9*(2002*G + 200)^2))/(((G/(4004*G + 400) + (2004*G + 200*G*r + 1001*G^2*r + 200)^3/(27*(2002*G + 200)^3) - ((1003*G + 200*G*r + G^2*r)*(2004*G + 200*G*r + 1001*G^2*r + 200))/(6*(2002*G + 200)^2))^2 + ((1003*G + 200*G*r + G^2*r)/(6006*G + 600) - (2004*G + 200*G*r + 1001*G^2*r + 200)^2/(9*(2002*G + 200)^2))^3)^(1/2) + G/(4004*G + 400) + (2004*G + 200*G*r + 1001*G^2*r + 200)^3/(27*(2002*G + 200)^3) - ((1003*G + 200*G*r + G^2*r)*(2004*G + 200*G*r + 1001*G^2*r + 200))/(6*(2002*G + 200)^2))^(1/3))/2 + imag((2004*G + 200*G*r + 1001*G^2*r + 200)/(6006*G + 600)) - (3^(1/2)*(real(((1003*G + 200*G*r + G^2*r)/(6006*G + 600) - (2004*G + 200*G*r + 1001*G^2*r + 200)^2/(9*(2002*G + 200)^2))/(((G/(4004*G + 400) + (2004*G + 200*G*r + 1001*G^2*r + 200)^3/(27*(2002*G + 200)^3) - ((1003*G + 200*G*r + G^2*r)*(2004*G + 200*G*r + 1001*G^2*r + 200))/(6*(2002*G + 200)^2))^2 + ((1003*G + 200*G*r + G^2*r)/(6006*G + 600) - (2004*G + 200*G*r + 1001*G^2*r + 200)^2/(9*(2002*G + 200)^2))^3)^(1/2) + G/(4004*G + 400) + (2004*G + 200*G*r + 1001*G^2*r + 200)^3/(27*(2002*G + 200)^3) - ((1003*G + 200*G*r + G^2*r)*(2004*G + 200*G*r + 1001*G^2*r + 200))/(6*(2002*G + 200)^2))^(1/3)) + cos(arg(((G/(4004*G + 400) + (2004*G + 200*G*r + 1001*G^2*r + 200)^3/(27*(2002*G + 200)^3)-................
fx=@(x)f(x(1),x(2));
[x,fval]=fmincon(fx,[1,1],[],[],[],[],[0 0],[1 1])
but i have this error
Warning: To use the default trust-region-reflective algorithm you must supply the gradient in the objective function and set the GradObj option to 'on'. FMINCON will use the active-set algorithm instead.
For information on applicable algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 492
Undefined function 'arg' for input arguments of type 'double'.
Error in
@(G,r)atan((imag(((1003*G+200*G*r+G^2*r)/(6006*G+600)-(2004*G+200*G*r+1001*G^2*r+200)^2/(9*(2002*G+200)^2))/(((G/(4004*G+400)+(2004*G+200*G*r+1001*G^2*r+200)^3/(27*(2002*G+200)^3)-((1003*G+200*G*r+G^2*r)*(2004*G+200*G*r+1001*G^2*r+200))/(6*(2002....................
Error in @(x)f(x(1),x(2))
Error in fmincon (line 601)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
PLEASE HELP
0 Comments
Answers (2)
Matt J
on 17 Jun 2015
It means that your objective function produced an error when fmincon called it with a particular test value X. You can use dbstop to see what X was.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!