Info

This question is closed. Reopen it to edit or answer.

Error in evalObjAndConstr (line 139)

1 view (last 30 days)
Akbar Abdillah
Akbar Abdillah on 6 Feb 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
I am doing iteration which solving a fmincon problem at each time. But then I meet this error
Operands to the || and && operators must be convertible to logical scalar values.
Error in evalObjAndConstr (line 139)
Error in sqpLineSearch (line 291)
Error in fmincon (line 915)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpLineSearch(funfcn,X,full(A),full(B),full(Aeq),full(Beq), ...
Error in coba_mpc1 (line 265)
[x,fval] = fmincon(cost,x0,A,B,Aeq,Beq,lb,ub,[],options);
Where should I check for my wrong?

Answers (1)

Walter Roberson
Walter Roberson on 6 Feb 2016
Your "cost" is not a function handle, or if it is a function handle, it is not returning a scalar, or you have options turned on that expect your function to return the gradient and you are not returning the expected shape.
It is difficult to be more specific without seeing your code.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!